Javascript DOM HTML Input Submit type Property get

Introduction

Find out which type of form element the Submit button is:

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="submit" id="mySubmit">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from   ww w .ja  v  a 2s.  c o  m*/
  var x = document.getElementById("mySubmit").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element a submit button is.

For a submit button object, this property will always return "submit".




PreviousNext

Related