html - 用户不应该能够选择已经选择的按钮

标签 html twitter-bootstrap button

按钮组没有正常工作,问题是如果选择了“ON”,则不应再次选择它,但问题是即使选择了“ON”按钮我我能够再次选择 ON 按钮。

当按钮已被选中时,如何停止我的按钮以停止任何操作。

这是我的按钮组代码:

<form action="myclass.php" method="post">
    <div class="btn-group" data-toggle="buttons">
        <label class="btn btn-default btn-xs myOnbutton">
            // myOnbutton is the button name
            <input type="radio" autocomplete="off"> ON
        </label>
        <label class="btn btn-default btn-xs myOffbutton">
            // myOffbutton is the button name
            <input type="radio" autocomplete="off"> OFF
        </label>
    </div>
</form>

有谁知道我哪里出错了,所以是重新选择按钮。

最佳答案

这是基本的 HTML。它与 bootstrap 无关,您只需要在复选框中添加名称,这样您就不能同时选择两者。

<label class="btn btn-default btn-xs myOnbutton">
    <input type="radio" autocomplete="off" name="switch"> ON
  </label>
  <label class="btn btn-default btn-xs myOffbutton">
    <input type="radio" autocomplete="off" name="switch"> OFF
  </label>

关于html - 用户不应该能够选择已经选择的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31915421/

相关文章:

javascript - 使用 JavaScript 获取 div 中的元素

html - 推特 Bootstrap 表对齐

javascript - 使用 CSS 媒体查询时不打印背景

css - 我正在关注 Codecademy rails turorial 并坚持使用 bootstrap

html - 移动布局不呈现宽度 : 100%

javascript - Twitter Bootstrap 的工具提示

JavaScript代码在IE8中不起作用

html - 为什么 css "font-family:inherit"会影响 Chrome 中 <select> 的颜色? (举例)

ios - Swift - 添加 UIView 后按钮不可点击

java - 在 Java 中向按钮添加(内置?)图标?