It is very simple to select a radio using JQuery dynamically.
Here are the example:
<input type="radio" name="sex" value="Male">Maleinput>
<input type="radio" name="sex" value="Female">Femaleinput>
If you want to select radio button (Male)
$('input:radio[name=sex]:nth(0)').attr('checked',true);
or
$('input:radio[name=sex]')[0].checked = true;
Radio button index starts from 0, means for Male index will be 0 and for Female 1.
If you want to select radio buton(Female)
$('input:radio[name=sex]:nth(1)').attr('checked',true);
or
$('input:radio[name=sex]')[1].checked = true;
If you want to get selected radio button value
$('input:radio[name=sex]:checked').val();
Check live example here:
http://jsfiddle.net/jeetu_verma11/tgXKd/
nice.......
ReplyDelete