I have many button in a row in my page. And I need to change the button color, when I click on the Buttons. Here is My sample code
$( "button.change" ).click(function() {
$(this).toggleClass( "selected" );
});
.Button {
font-family: Calibri, sans-serif;
font-size:13px;
font-weight: bold;
width: 160px;
height: 25px;
background:grey;
color: white
}
.selected {
color: white;
background:green
}
button#cssColorChange:active{
color: white;
background:red
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<button class="Button change" id="jQueryColorChange">Click to change color</button>
<br><br>
<button class="Button change" id="jQueryColorChange">Click to change color</button>
<br><br>
<button class="Button change" id="jQueryColorChange">Click to change color</button>
<br><br>
<button class="Button change" id="jQueryColorChange">Click to change color</button>
Here it is Working. But here when I click on every buttons, color has been changed. I need, When I click on one Button, color should change for that Button only and the remaining Buttons color should default.