Search w3schools.com:

SHARE THIS PAGE

Checkbox checked Property

Checkbox Object Reference Checkbox Object

Definition and Usage

The checked property sets or returns the checked state of a checkbox.

Syntax

Set the checked property:

checkboxObject.checked=true|false

Return the checked property:

checkboxObject.checked


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The checked property is supported in all major browsers.


Example

Example

Set the checked state of a checkbox:

<html>
<head>
<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 »


Examples

More Examples

Checkbox - Convert text to uppercase

Several checkboxes in a form


Checkbox Object Reference Checkbox Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]