我有几个按钮。当用户点击任何按钮时,我想给他的印象是按钮被点击了。
这是代码:
<table>
<thead>
<tr>
<th><button class="btn btn-danger" >Today</button></th>
<th><button class="btn btn-danger" >Tomorrow</button></th>
<th><button class="btn btn-danger" >DayAfterTomorrow</button></th>
</tr>
</thead>
</table>
这在我只有一个按钮时有效:
<button class="btn" data-toggle="button">Today</button>
如果用户点击明天,今天按钮的数据切换属性仍然保留。相反,我想在单击另一个按钮时禁用 data-toggle 属性。
最佳答案
您可以使用 Bootstrap 单选按钮功能来实现该效果。试试这个:
<div data-toggle="buttons-radio">
<button class="btn btn-danger">Today</button>
<button class="btn btn-danger">Tomorrow</button>
<button class="btn btn-danger">DayAfterTomorrow</button>
</div>
关于jquery - Bootstrap - 存在多个按钮时的数据切换属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11374642/