Bootstrap - 存在多个按钮时的数据切换属性

Pav*_*van 5 css jquery twitter-bootstrap

我有几个按钮.当用户点击任何按钮时,我想给他一个点击按钮的印象.

这是代码:

<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>
Run Code Online (Sandbox Code Playgroud)

当我只有一个按钮时,这可以工作:

<button class="btn" data-toggle="button">Today</button>
Run Code Online (Sandbox Code Playgroud)

如果用户明天点击,则数据切换属性仍保留为今日按钮.相反,我想在单击另一个按钮时禁用数据切换属性.

And*_*ich 5

您可以使用bootstraps单选按钮功能来实现该效果.试试这个:

<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>
Run Code Online (Sandbox Code Playgroud)

演示:http://jsfiddle.net/u7Lg8/