Working on a site with multiple buttons, all I want the buttons to do it when you click on them change color. Example. Click button 1 and button 1 changes from white to yellow. Click on button 2 and button 2 changes from white to yellow. Right now I have onclick in the button code and it works, except it changes all the buttons at once.
$(document).ready(function() {
$(".button").click(function() {
$(".button").css('background', 'yellow');
});
});
.button {
background-color: #FFFFFF;
/* White */
border: 2px solid #f44336;
color: black;
padding: 10px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 30px;
border-radius: 50%;
width: 60px;
text-align: center;
cursor: pointer
}
.disabled {
background-color: #FF0000;
/* Red */
color: white;
cursor: not-allowed;
}
.button-clicked {
background-color: #FFFF00;
/* Yellow */
}
td:not(:first-child) {
padding-top: 5px;
padding-bottom: 5px;
padding-right: 5px;
}
<script src="Https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table width="100%" border=1>
<tr>
<td align="center"><button class="button" id="1" onclick="myFunction()">1</button></td>
<td align="center"><button class="button" id="2" onclick="myFunction()">2</button></td>
<td align="center"><button class="button" id="3" onclick="myFunction()">3</button></td>
</tr>
</table>