The type
property returns the type of form element.
For an input button this property will always return "button".
type |
Yes | Yes | Yes | Yes | Yes |
var v = buttonObject.type
A String type value representing the type of input button.
The following code shows how to get the type of a button.
<!DOCTYPE html>
<html>
<body>
<input type="button" onclick="myFunction()" id="myBtn" value="test">
<p id="demo"></p>
<script>
function myFunction() {<!--from ww w . j a v a2 s. c o m-->
var x = document.getElementById("myBtn").type;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: