In this from, how to select with jquery the latest radiobutton was selected by the user
<form id = "myform">
<h3>Time to work?</h3>
<p>
<input type="radio" name="work" value="Hourly" />
<input type="radio" name="work" value="Daily" />
<input type="radio" name="work" value="Weekly" />
</p>
<h3>Your Age?</h3>
<p>
<input type="radio" name="age" value="old" />
<input type="radio" name="age" value="young" />
<input type="radio" name="age" value="child" />
</p>
</form>
I tried
$('input:checked', '#myform').val();
and
$('input[type='radio']:checked', '#myform').val();
but it always select the only value of the first question! any help?
Try this :
<script type="text/javascript"> jQuery("input[type=radio]").click(function(){ alert(jQuery(this).val()); }); </script>