Javascript DOM HTML Input Submit Object get

Introduction

The Input Submit object represents an HTML <input> element with type="submit".

We can access an <input> element with type="submit" via document.getElementById():

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

Click the button to get the text displayed on the submit button.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="submit" id="mySubmit" value="Submit the form">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//from  w  w w. ja  v  a  2  s  .  com
  var x = document.getElementById("mySubmit").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related