按钮组没有正常工作,问题是如果选择了“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/