Easy Tutorial
❮ Jsref Includes Prop Video Loop ❯

Checkbox checked Attribute


Definition and Usage

The checked attribute sets or returns whether a checkbox should be checked.

Syntax

Set the checked attribute:

Return the checked attribute:


Browser Support

All major browsers support the checked attribute.


Example

The following example sets the state of the checkbox:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</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()">Confirm Checkbox</button>
<button onclick="uncheck()">Uncheck Checkbox</button>

</body>
</html>

More Examples

Checkbox - Convert Text to Uppercase

Multiple Checkboxes in a Form


❮ Jsref Includes Prop Video Loop ❯