Input Radio checked Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Radio


The checked property sets or gets the checked state of a radio button.

This property reflects the HTML checked attribute.

Set the checked property with the following Values

Value Description
true|false Sets whether a radio button should be checked

Return Value

A Boolean, returns true if the radio button is checked, and false if the radio button is not checked

The following code shows how to Check and un-check a specific radio button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

  What color do you prefer?<br>
  <input type="radio" name="colors" id="red">Red<br>
  <input type="radio" name="colors" id="blue">Blue
</form>//from w  ww.j a  va  2s .c o m

<button onclick="check()">Check "Red"</button>
<button onclick="uncheck()">Uncheck "Red"</button>

function check() {
    document.getElementById("red").checked = true;
function uncheck() {
    document.getElementById("red").checked = false;


Related Tutorials