Input Email name attribute
Definition and Usage
name
Set or return the value of the name attribute of the email field.
The HTML name attribute is used to identify form data after the form data is submitted to the server, or to reference form data on the client using JavaScript.
Note:Only form elements that have a name attribute will pass their values when the form is submitted.
See also:
HTML Reference Manual:HTML <input> name 属性
Example
Example 1
Get the name of the email field:
var x = document.getElementById("myEmail").name;
Example 2
Change the name of the email field:
document.getElementById("myEmail").name = "newEmailName";
Syntax
Return name attribute:
emailObject.name
设置 name 属性:
emailObject.name = name
属性值
值 | 描述 |
---|---|
name | 规定电子邮件字段的名称。 |
技术细节
返回值: | 字符串值,表示电子邮件字段的名称。 |
---|
浏览器支持
表中的数字注明了首个完全支持该属性的浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 10.0 | 支持 | 支持 | 支持 |