Javascript DOM HTML Input Email defaultValue Property get

Introduction

Get the default value of an email field:

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

Click the button to display the default value 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 w  w  . j  a va2  s  . c  o m
  var x = document.getElementById("myEmail").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related