JQuery get selected radio value
Here is the html code.
<input type="radio" name="sex" value="0" /> <input type="radio" name="sex" value="1" />
When one of them is selected, we can use the following code to get the value.
$("input[@name='sex']").change(function(){ if ($("input[@name='sex']:checked").val()) alert("female"); else alert("male"); });
Of course, you can use JQuery’s form plugin, but to get a radio’s value, there is no need to do that.
Related posts:
Leave a comment
Comments(0)