Checkbox checkedProperty
Checkbox Object
Definition and Usage
The checked property sets or returns whether a checkbox should be checked.
Syntax
Set the checked property:
checkboxObject.checked=true|false
Return the checked property:
checkboxObject.checked
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the checked property
Examples
Examples
The following example can set the state of the checkbox:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.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()">Check checkbox</button>
<button onclick="uncheck()">Uncheck checkbox</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.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()">Check checkbox</button>
<button onclick="uncheck()">Uncheck checkbox</button>
</body>
</html>
Try it Yourself »
More Examples
Checkbox - Convert text to uppercase
Checkbox Object Other extensions