Javascript Reference - HTML DOM Input Checkbox type Property








The type property returns the type of the checkbox.

For a checkbox this property will always return "checkbox".

Browser Support

type Yes Yes Yes Yes Yes

Syntax

var v = checkboxObject.type 

Return Value

Type Description
String The type of the checkbox is




Example

The following code shows how to get 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  . jav a  2 s  .c  o m-->
    var x = document.getElementById("myCheck").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: