This post will discuss how to set a radio button in JavaScript and jQuery.

1. Using jQuery

With jQuery, you can use the .prop() method to set the checked property of the radio button.

JS


HTML



Edit in JSFiddle

 
Alternatively, you can simply simulate the mouse-click for a radio button using jQuery’s .click() method. This is equivalent to calling .trigger('click').

JS


HTML



Edit in JSFiddle

2. Using JavaScript

With plain JavaScript, you can use the checked property to set the value of a radio button.

JS


HTML



Edit in JSFiddle

That’s all about setting a radio button in JavaScript and jQuery.