Latest web development tutorials

HTML DOM Radio defaultChecked property

Radio Object Reference Radio Objects

Definition and Usage

defaultChecked property returns the default value for the property checked.

If the default radio button is selected, it returns true, otherwise fasle.

grammar

radioObject.defaultChecked


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support defaultChecked property


Examples

Examples

Detection "Blue" option is selected by default:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function displayResult () {
var x = document.getElementById ( "blue") defaultChecked.;
alert (x);
}
</ Script>
</ Head>
<Body>

<Form>
Which color do you prefer? <br>
<Input type = "radio" name = "colors" id = "red"> red <br>
<Input type = "radio" name = "colors" id = "blue" checked = "checked"> Blue <br>
<Input type = "radio" name = "colors" id = "green"> green
</ Form>
<Button type = "button" onclick = "displayResult ()"> select the default blue it? </ Button>

</ Body>
</ Html>

try it"


Radio Object Reference Radio Objects