tags:

views:

25

answers:

2

I have two radio button in my view..

something like this..

 <input type="radio" name="ObnCategory" 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

+2  A: 

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();
Graphain
based on the OP's I think that can not be applied... :)
Reigel
+1  A: 

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

Reigel