Toggle on multiple button or anchors
Toggle on multiple button or anchors
by Keyur Patel
HTML
<div class="activeTab">
<a href="#" class="active">Active</a>
<a href="#">Inactive</a>
</div>
CSS
.active{
background-color:red;
}
.inactive{
background-color:green;
}
JavaScript
$('div.activeTab a').click(function(){
var $this = $(this);
$this.siblings().removeClass();
if($this.hasClass('active')){
$this.removeClass('active').addClass('inactive')
}else{
$this.removeClass('inactive').addClass('active');
}
})