Javascript DOM HTML Input Email value Property get

Introduction

Get the email address of an email field:

var x = document.getElementById("myEmail").value;

Click the button to display the email address of the email field.

View in separate window

<!DOCTYPE html>
<html>
<body>

E-mail: <input type="email" id="myEmail" value="css@example.com">

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/* w ww .  j a v  a2  s .  com*/
  var x = document.getElementById("myEmail").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related