Input Radio defaultChecked Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Radio


The defaultChecked property returns the default value of the checked attribute.

Return Value

Boolean Returns true if the radio button is checked by default, otherwise it returns false.

The following code shows how to Check if a radio button is checked by default:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

Radio button: <input type="radio" name="colors" id="myRadio" checked>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {//from   w  w w.j  ava2s .c om
    var x = document.getElementById("myRadio").checked;
    document.getElementById("demo").innerHTML = x;


Related Tutorials