Problem with using radios values on Jquery
for example i have this code in HTML
<div>
<input type="radio" id="respuesta1" name="respuesta" class="respuesta" value="1">
</div>
<div>
<input type="radio" id="respuesta2" name="respuesta" class="respuesta" value="2">
</div>
<div>
<input type="radio" id="respuesta3" name="respuesta" class="respuesta" value="3">
</div>
<div>
<input type="radio" id="respuesta4" name="respuesta" class="respuesta" value="4">
if i do on Jquery
if ($('#respuesta1').is(':checked')) {
alert ("1 is checked");
}
that is all good, but what i want to do is to check it from value, i dont know if i make myself clear.
for example i have a random variable
var num = a random number from 1 to 4;
and i want to check if the radio with the value of my number is checked how do i do?