Input Button typeProperty
Button Object
Definition and Usage
The type property returns the type of the form element.
The type of a Button object is always "button".
Syntax
buttonObject.type
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the type property
Example
Example
The following example returns the form element type of the button:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("button1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="button" onclick="displayResult()" value="Show button type" id="button1">
</form>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("button1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="button" onclick="displayResult()" value="Show button type" id="button1">
</form>
</body>
</html>
Try it yourself »
Button Object Other Extensions