Categories
Uncategorized

How to get the selected radio button value using jquery ?

Demo on jsFiddle: http://jsfiddle.net/yrshaikh/H6bhE/

Html :

<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="none">I dont want to disclose :)
<input id="submitBtn" type="submit" value="submit" />
Jquery :
$("#submitBtn").bind("click", function(){
var myRadio = $('input[name=gender]');
var checkedValue = myRadio.filter(':checked').val();
alert(checkedValue);
});​
Another way of doing this would be...
$("input[name='gender']:checked").val()
Further Reading :
How can I get which radio is selected via jQuery?