Button Group Active Class
by tomsx
HTML
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<div class="btn-group">
<button type="button" class="active myButton" id="regi1">Left</button>
<button type="button" class="myButton" id="regi2">Middle</button>
<button type="button" class="myButton" id="regi3">Middle</button>
<button type="button" class="myButton" id="regi4">Right</button>
<button type="button" class="myButton" id="regi4">Right</button>
</div>
CSS
body{padding:50px;}
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #fce2c1;
-webkit-box-shadow:inset 0px 1px 0px 0px #fce2c1;
box-shadow:inset 0px 1px 0px 0px #fce2c1;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #fac584), color-stop(1, #fb9e25));
background:-moz-linear-gradient(top, #fac584 5%, #fb9e25 100%);
background:-webkit-linear-gradient(top, #fac584 5%, #fb9e25 100%);
background:-o-linear-gradient(top, #fac584 5%, #fb9e25 100%);
background:-ms-linear-gradient(top, #fac584 5%, #fb9e25 100%);
background:linear-gradient(to bottom, #fac584 5%, #fb9e25 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fac584', endColorstr='#fb9e25',GradientType=0);
background-color:#fac584;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #eeb44f;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:12px;
padding:6px 16px;
text-decoration:none;
text-shadow:0px 1px 0px #cc9f52;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #fb9e25), color-stop(1, #fac584));
background:-moz-linear-gradient(top, #fb9e25 5%, #fac584 100%);
background:-webkit-linear-gradient(top, #fb9e25 5%, #fac584 100%);
background:-o-linear-gradient(top, #fb9e25 5%, #fac584 100%);
background:-ms-linear-gradient(top, #fb9e25 5%, #fac584 100%);
background:linear-gradient(to bottom, #fb9e25 5%, #fac584 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fb9e25', endColorstr='#fac584',GradientType=0);
background-color:#fb9e25;
}
.myButton:active {
position:relative;
top:1px;
background-color:red;
}
JavaScript
$(".btn-group > .btn").click(function(){
$(".btn-group > .btn").removeClass("active");
$(this).addClass("active");
});