I want to modify the class of a button according to its id and its value. Each <button>
has equal identifiers, but different values.
I have tried this way below, however only the first button is modified, regardless of the value that is entered for the value
variable. For this case below you should modify the class for the MARCLE text button.
var value = 4;
$("#month").val(value).attr('class', 'btn btn-primary btn-xs');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/>
<div style="margin: 20px">
<button id="month" type="button" class="btn btn-default btn-xs" value="1">BALACO BACCO</button>
<button id="month" type="button" class="btn btn-default btn-xs" value="2">CAPTÃO G.NASCIMENTO</button>
<button id="month" type="button" class="btn btn-default btn-xs" value="3">JBUENO'S DIA</button>
<button id="month" type="button" class="btn btn-default btn-xs" value="4">MARCELEZA</button>
</div>
How can I change the class of a button according to its id and value?