Scenario
I would like the user to be able to switch through Twitter Bootstrap button classes using jQuery when the main part of the button is pressed (for quick).
or
Allow user to select state from dropdown menu.
Regardless of the selected state, the entire btn-group must have the same class of buttons.
Not Running (btn-info), In Progress (btn-warning), Completed (btn-success) and Late (btn-error).
What i wish

What am i still
This is my HTML code. This is a standard Bootstrap button group.
<div class="btn-group">
<button type="button" class="btn btn-warning">Week 7</button>
<button type="button" class="btn btn-warning dropdown-toggle"
data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#">Not Started</a>
</li>
<li>
<a href="#">In Progress</a>
</li>
<li>
<a href="#">Completed</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Late</a>
</li>
</ul>
</div>
This switches all buttons, not just the button that the button is pressed on.
$('.btn-group').click(function () {
var classes = ['btn btn-info','btn btn-info','btn btn-success'];
$('.btn').each(function(){
this.className = classes[($.inArray(this.className, classes)+1)%classes.length];
});
});
source
share