禁用按钮点击但启用另一个按钮

编程入门 行业动态 更新时间:2024-10-26 00:20:06
本文介绍了禁用按钮点击但启用另一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的页面上有两个不同的按钮.我希望在页面加载时启用它们,但是当用户单击一个按钮时,我想禁用另一个按钮.但是,如果他们单击另一个按钮,我希望在启用另一个禁用按钮的同时禁用该按钮.我已经能够禁用 onclick 按钮,但是我无法让另一个按钮重新启用.这是我在页面上的两个按钮.它们不是在表单中,而是在页面上.

I have two different buttons on my page. I want them both to be enabled when the page loads, but when a user clicks one I would like to disable the other button. But if they click the other button, I would like that button to disabled as well while enabling the other disabled button. I have been able to disable the button onclick, but I'm having trouble getting the other button to re-enable . Here are the two buttons that I have on the page. They are not in a form, just on the page.

<button onclick="down7913.disabled=false" type="submit" class="positive" name="up7913"><img src="check.png" alt=""/></button>

<button onclick="this.disabled=true" type="submit" class="negative" name="down7913"><img src="cross.png" alt=""/></button>

推荐答案

检查此代码,它符合您的口味并且正在工作:

Check this code, it's in your flavour and working:

代码片段 -

<button
    onclick="this.disabled=true;document.getElementById('down7913').disabled=false;"
    type="submit"
    class="positive"
    name="up7913"
    id="up7913"
  >
    First
  </button>

  <button
    onclick="this.disabled=true;document.getElementById('up7913').disabled=false;"
    type="submit"
    class="negative"
    name="down7913"
    id="down7913"
  >
    Second
  </button>

这篇关于禁用按钮点击但启用另一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 12:14:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1135385.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!