Input Email value attribute
Definition and Usage
value
Set or return the value of the value attribute of the email field.
The HTML value attribute specifies the default value or the value entered by the user (or the value set by the script).
The value can be a single email address or a list of email addresses.
See also:
HTML Reference Manual:HTML <input> value 属性
Example
Example 1
Change the email address in the email field:
document.getElementById("myEmail").value = "steve@codew3c.com";
Example 2
Get the email address from the email field:
var x = document.getElementById("myEmail").value;
Example 3
Example to show the difference between defaultValue and value attributes:
var x = document.getElementById("myEmail"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return value attribute:
emailObject.value
Set value attribute:
emailObject.value = text
属性值
值 | 描述 |
---|---|
text | 规定单个电子邮件地址或电子邮件地址列表。 |
技术细节
返回值: | 字符串值或逗号分隔的字符串列表,表示有效的电子邮件地址。 |
---|
浏览器支持
表中的数字注明了首个完全支持该属性的浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 10.0 | 支持 | 支持 | 支持 |