HTML DOM Checkbox defaultChecked property
Definition and Usage
defaultChecked property returns the default value for the property checked.
This property returns true if the checkbox is selected by default, otherwise it returns false.
grammar
checkboxObject.defaultChecked
Browser Support
All major browsers support defaultChecked property
Examples
Examples
The following example returns the value of the checked property:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function displayResult () {
var x = document.getElementById ( "myCheck") defaultChecked.;
alert (x);
}
</ Script>
</ Head>
<Body>
<Form>
<Input type = "checkbox" id = "myCheck" checked = "checked"> do you like summer?
</ Form>
<Button type = "button" onclick = "displayResult ()"> select the default selection box do? </ Button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function displayResult () {
var x = document.getElementById ( "myCheck") defaultChecked.;
alert (x);
}
</ Script>
</ Head>
<Body>
<Form>
<Input type = "checkbox" id = "myCheck" checked = "checked"> do you like summer?
</ Form>
<Button type = "button" onclick = "displayResult ()"> select the default selection box do? </ Button>
</ Body>
</ Html>
try it"
Checkbox objects