If the .active class .active not be removed from the active button after clicking, use addClass instead of toggelClass
$("#header .btn-group[role='group'] button").on('click', function(){ $(this).siblings().removeClass('active') $(this).addClass('active'); })
Jsfiddle example
Good practice is to narrow down the selection of buttons, I used #heade id and .btn-group[role='group'] , which makes the script apply only to buttons inside all button groups iside <div id="header"></div>
and here you have the class definition .active :
.btn.active{ background-color: red; }
tutok source share