W3Schools.com

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 type="text/javascript">
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
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE