I have two radio button in my view..
something like this..
<input type="radio" name="ObnCatego开发者_高级运维ry" id="Obncategory" checked="checked" />X</div><br />
<div>
<input type="radio" name="ObnCategory" id="Obnsubcategory" />Y</div><br />
I need to see which one is checked or not using jquery?
thanks
Try this:
$("input:radio:checked").val();
i.e.:
if ($("input:radio:checked").val() == "X") {
}
else if ($("input:radio:checked").val() == "Y") {
}
In your particular updated example try this:
$("input:radio:checked").next().text();
why not add a label
...
<div>
<input type="radio" name="ObnCategory" id="Obncategory" checked="checked" />
<label for="Obncategory">X</label>
</div>
<div>
<input type="radio" name="ObnCategory" id="Obnsubcategory" />
<label for="Obnsubcategory">Y</label>
</div>
then
$(function(){
$(':radio:checked').next('label').text() // would get the value
})
play with the demo here
精彩评论