Checkbox typeProperty
Checkbox Object
Definition and Usage
The type property returns the form element type of the element.
For a checkbox object, this property always returns "checkbox".
Syntax
checkboxObject.type
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the type property
Example
Example
The following example returns the form element type of the checkbox:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("check1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1">Do you like summer?
</form>
<button type="button" onclick="displayResult()">Display input type</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("check1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1">Do you like summer?
</form>
<button type="button" onclick="displayResult()">Display input type</button>
</body>
</html>
Try it yourself »
Checkbox Object Other Extensions