Javascript DOM HTML Input Email Object get

Introduction

The Input Email object represents an HTML <input> element with type="email".

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

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

Click the button to get the e-mail address of the email field.

View in separate window

<!DOCTYPE html>
<html>
<body>
E-mail: <input type="email" id="myEmail" value="john@example.com">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from  ww w . j a  va  2s . c  o  m*/
  var x = document.getElementById("myEmail").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related