Change the email address of an email field:
document.getElementById("myEmail").value = "html@example.com";
Click the button to change the email address of the email field.
<!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() {/*from w w w. java2 s. c om*/ document.getElementById("myEmail").value = "html@example.com"; } </script> </body> </html>
The value
property sets or gets the value attribute of an email field.
The value attribute specifies the default value OR the value a user types in.
The value can be a single e-mail address, or a list of e-mail addresses.
The value
property accepts and returns a String type value.
It can be a single e-mail address, or a list of e-mail addresses.
The value
property returns a String representing a valid email address.