Friday, November 21, 2014

Change selected input of a radio button using jquery

Change selected input of a radio button using jquery

Html
<form action="">
    <input type="radio" name="option" value="option1">1<br>
    <input type="radio" name="option" value="option2">2<br>
    <input type="radio" name="option" value="option3">3<br>
    <input type="radio" name="option" value="option4">4
</form>
Jquery code
$("input[value='option3']").prop("checked", true);
Note that you can also add events to change the selected option like OnClick.

Live Demo

No comments:

Post a Comment