Find out type of the checkbox:
var x = document.getElementById("myCheck").type;
Check the checkbox to display checkbox's type.
<!DOCTYPE html> <html> <body> <input type="checkbox" onclick="myFunction()" id="myCheck"> <p id="demo"></p> <script> function myFunction() {/*from w w w. j a v a 2 s. com*/ var x = document.getElementById("myCheck").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type
property returns type of the checkbox.
For a checkbox this property will always return "checkbox".
Type | Description |
---|---|
String | The type of form element the checkbox is |