I have a <div> with rabioboxs:
<div id='RB-01'>
<span>Item_1</span><input type='radio' name='RB01' value='1'><br />
<span>Item_2</span><input type='radio' name='RB01' value='2'><br />
<span>Item_3</span><input type='radio' name='RB01' value='3'><br />
</div>
Then with jquery I want to get a radiobox that was checked:
var obj = null;
var tempId = "RB-01";
if ($('div[id=' + tempId + ']')) {
$('div[id=' + tempId + '] input').each(function() {
if ($(this).checked == true) { obj = $(this); }
});
}
but in the end obj = null.
You should do:
or
Of course rember to have at least on of the checkbox checked. Fiddle here http://jsfiddle.net/nicolapeluchetti/Ky6q2/ and here http://jsfiddle.net/nicolapeluchetti/TEw53/