HTML DOM Checkbox checked property
Definition and Usage
checked property sets or returns whether a checkbox should be checked.
grammar
Setting checked properties:
checkboxObject.checked=true|false
Returns checked attributes:
checkboxObject.checked
Browser Support
All major browsers support checked property
Examples
Examples
The following examples set the status of the checkbox:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function check () {
document.getElementById ( "check1"). checked = true
}
function uncheck () {
document.getElementById ( "check1"). checked = false
}
</ Script>
</ Head>
<Body>
<Form>
<Input type = "checkbox" id = "check1"> do you like summer?
</ Form>
<Button onclick = "check ()"> to confirm the selection box </ button>
<Button onclick = "uncheck ()"> does not confirm the selection box </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function check () {
document.getElementById ( "check1"). checked = true
}
function uncheck () {
document.getElementById ( "check1"). checked = false
}
</ Script>
</ Head>
<Body>
<Form>
<Input type = "checkbox" id = "check1"> do you like summer?
</ Form>
<Button onclick = "check ()"> to confirm the selection box </ button>
<Button onclick = "uncheck ()"> does not confirm the selection box </ button>
</ Body>
</ Html>
try it"
More examples
Checkbox - the text is converted to uppercase
Checkbox objects