HTML DOM Input Checkbox Object

Input Checkbox object

The Input Checkbox object represents an HTML <input> element with type="checkbox" set.

Access Input Checkbox Object

You can use getElementById() to access the <input> element with type="checkbox":

var x = document.getElementById("myCheck");

Try it yourself

Tip:You can also traverse the form's elements collection to access <input type="checkbox">.

Create Input Checkbox Object

You can use the document.createElement() method to create an <input> element with type="checkbox":

var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");

Try it yourself

Input Checkbox Object Properties

Attributes Description
autofocus Set or return whether the checkbox should automatically focus when the page is loaded.
checked Set or return the selected state of the checkbox.
defaultChecked Return the default value of the checked property.
defaultValue Set or return the default value of the checkbox.
disabled Set or return whether the checkbox is disabled.
form Return a reference to the form that contains the checkbox.
indeterminate Set or return the indeterminate state of the checkbox.
name Set or return the value of the checkbox's name property.
required Set or return whether the checkbox must be selected before submitting the form.
type Return the type of form element that the checkbox is.
value Set or return the value of the checkbox's value property.

Standard properties and events

The Input object supports both standardsAttributesandEvents.

Related pages

HTML Tutorial:HTML Form

HTML Reference Manual:HTML <input> Tag

HTML Reference Manual:HTML <input> type Attribute