Javascript DOM HTML Input Button type Property get

Introduction

Return which type of form element the input button is:

var x = document.getElementById("myBtn").type;

Click the input button to find out which type of form element it is.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="button" onclick="myFunction()" id="myBtn" value="Test">

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

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

</body>
</html>

The type property returns which type of form element the input button is.

For an input button this property will always return "button".




PreviousNext

Related