HTML DOM Input Checkbox Object Last Updated : 11 Jan, 2024 Comments Improve Suggest changes Like Article Like Report The input checkbox object in HTML represents a checkbox in an HTML form. For each instance of an <input type = "checkbox"> element in an HTML form, a checkbox object is created. To access the checkbox object use indexing the elements array of the corresponding form or by using objects(); Table of Content Creating checkbox object Accessing checkbox object Creating checkbox object: We can create checkbox objects through JavaScript. To create <input type = "checkbox"> element use document.createElement() method. After creation use the appendChild() method to append it to the particular element (such as div) to display it. Syntax:let a = document.createElement("container");a.setAttribute("type", "container");Example 1: This example illustrates, how to create a checkbox object in an HTML document. html <!DOCTYPE html> <html> <head> <title> HTML DOM Input Checkbox object </title> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Creating an Input Checkbox Object</h2> <p>Click the button to create a checkbox.</p> <button onclick="geek()">Click me!</button> <br> <div id="myDiv"></div> <script> function geek() { let myDiv = document.getElementById("myDiv"); // creating checkbox element let checkbox = document.createElement('input'); // Assigning the attributes to created checkbox checkbox.type = "checkbox"; checkbox.name = "name"; checkbox.value = "value"; checkbox.id = "id"; // creating label for checkbox let label = document.createElement('label'); // assigning attributes for the created label tag label.htmlFor = "id"; // appending the created text to // the created label tag label.appendChild(document.createTextNode('This is the label for checkbox.')); // appending the checkbox and label to div myDiv.appendChild(checkbox); myDiv.appendChild(label); } </script> </body> </html> Output: Accessing checkbox object: We can access the checkbox object by using the getElementById() method. Put the id of the checkbox element in the getElementById() to access it. Syntax:let a = document.getElementById("container");Example 2: This example illustrates , how to access checkbox object in an HTML document. html <!DOCTYPE html> <html> <head> <title> HTML DOM Input Checkbox object </title> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Accessing checkbox object</h2> <p>Click the button to check the checkbox.</p> <button onclick="myFunction()">Click me!</button><br> Checkbox: <input type="checkbox" id="check"> <script> function myFunction() { // fetching the checkbox by id let doc = document.getElementById("check"); // changing the state of checkbox to checked doc.checked = true; } </script> </body> </html> Output: HTML DOM PropertyHTML DOM Input Checkbox value Property HTML DOM Input Checkbox form Property HTML DOM Input Checkbox checked PropertySupported Browsers: Google Chrome 1Edge 12Firefox 1Opera 15Safari 1 Comment More infoAdvertise with us Next Article HTML DOM Input Checkbox Object V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies HTML HTML-Property Similar Reads HTML | DOM Input Checkbox form Property The Input Checkbox form property in HTML DOM is used to return the reference of form containing the input Checkbox field. It is read only property that returns the form object on success. Syntax: checkboxObject.form Return Values: It returns a string value which specify the reference of the form con 1 min read HTML | DOM Input Checkbox type Property The Input Checkbox type Property in HTML DOM is used to return that which type of form element the checkbox is. For a checkbox input field, this Property was always return only "checkbox". Syntax: checkboxObject.type Return Value: It returns a string value which represents the type of form element t 1 min read HTML DOM Input Checkbox value Property HTML DOM Input Checkbox Value property sets or return the value of the value attribute of an input checkbox field, however the contents of the value attribute does not shown to user. It manages their assigned value, reflecting their state when checked or unchecked. It retrieves or sets the value att 3 min read HTML | DOM Input Checkbox checked Property The DOM Input Checkbox Property is used to set or return the checked status of a checkbox field. This property is used to reflect the HTML Checked attribute. Syntax: It is used to return the checked property.checkboxObject.checkedIt is used to set the checked property.checkboxObject.checked = true|f 2 min read HTML | DOM Input Checkbox disabled Property The Input Checkbox disabled property in HTML DOM is used to set or return whether the Input Checkbox field must be disabled or not. A disabled checkbox is unclickable and unusable. It is a boolean attribute and used to reflect the HTML Disabled attribute. Syntax: It returns the Input Checkbox disabl 2 min read HTML DOM Input Checkbox required Property The Input Checkbox required property in HTML DOM is used to set or return whether the input checkbox field should be checked or not before submitting the form. This property is used to reflect the HTML-required attribute. Syntax:It returns the Input Checkbox required property.checkboxObject.required 2 min read HTML | DOM Input Checkbox autofocus Property The DOM Input Checkbox Property is used to set or return whether the element should get focus when the page loads. This property is used to reflect the HTML autofocus attribute.Syntax: It is used to return the autofocus property. checkboxObject.autofocusIt is used to set the autofocus property. chec 2 min read HTML <input type="checkbox"> The HTML <input type="checkbox"> creates a checkbox input element. It displays as a square box, checked when activated. Checkboxes enable users to select one or more options from a limited set of choices. Syntax <input type="checkbox"> Example: In this example, we will demonstrate using 1 min read HTML | DOM Input Checkbox defaultValue Property The DOM Input Checkbox defaultValue Property is used to set or returns the default value of an Input Checkbox field. This property is used to reflect the HTML value attribute. The main difference between the default value and value is that the default value indicates the default value and the value 2 min read HTML DOM Input Checkbox indeterminate Property The input checkbox indeterminate property in HTML DOM is used to set or return whether the state of a checkbox has been changed or not. Basically, the checkbox has three state - true: It represent that status of checkbox is on.false: It indicates that checkbox status is unchecked or off.indeterminat 2 min read Like