Input Checkbox type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox

Description

The type property returns the type of form element.

For a checkbox this property always returns "checkbox".

Return Value

Type Description
String The type of form element the checkbox is

The following code shows how to check which type of form element the checkbox is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="checkbox" onclick="myFunction()" id="myCheck">

<p id="demo"></p>

<script>
function myFunction() {// ww  w . j  a  v a  2 s . c om
    var x = document.getElementById("myCheck").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials