

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Checkbox type Property
The Input Checkbox type property returns/sets type of Input Checkbox.
Syntax
Following is the syntax −
- Returning string value
inputCheckboxObject.type
- Setting type to string value
inputCheckboxObject.type = stringValue
String Values
Here, “stringValue” can be the following -
stringValue | Details |
---|---|
checkbox | It defines that input type is checkbox |
radio | It defines that input type is radio |
text | It defines that input type is text |
Example
Let us see an example of Input Checkbox type property −
<!DOCTYPE html> <html> <head> <title>Type Attribute of Checkbox</title> </head> <body> <form id="Form"> <div> Other: <input id="formCheckbox" type="checkbox" name="formCheckbox"> </div> </form> <button onclick="changeType()">Change type of input</button> <div id="displayDiv"></div> <script> var typeOfInput = document.getElementById("formCheckbox"); var displayDiv = document.getElementById("displayDiv"); displayDiv.textContent = 'Type of Input: ' + typeOfInput.type function changeType(){ if(typeOfInput.type == 'checkbox'){ typeOfInput.type = 'text' displayDiv.textContent = 'Type of Input: ' + typeOfInput.type } } </script> </body> </html>
Output
This will produce the following output −
Before clicking ‘Change type of input’ button −
After clicking ‘Change type of input’ button −
- Related Questions & Answers
- HTML DOM Input Checkbox checked Property
- HTML DOM Input Checkbox defaultChecked Property
- HTML DOM Input Checkbox autofocus Property
- HTML DOM Input Checkbox disabled Property
- HTML DOM Input Checkbox form Property
- HTML DOM Input Checkbox name Property
- HTML DOM Input Checkbox required Property
- HTML DOM Input Checkbox value Property
- HTML DOM Input Button type Property
- HTML DOM Input Month type Property
- HTML DOM Input FileUpload type Property
- HTML DOM Input Hidden type Property
- HTML DOM Input Color type Property
- HTML DOM Input Date type Property
- HTML DOM Input Time type Property
Advertisements