Input Hidden name attribute

Definition and Usage

name Sets or returns the value of the name attribute of the hidden input field.

The HTML name attribute is used to identify form data submitted to the server, or to reference form data on the client using JavaScript.

Note:Only form elements with a name attribute will pass their values when submitting the form.

See also:

HTML Reference Manual:HTML <input> ɗanar ƙarfin ɗanar

Instance

Example 1

Get the name of the hidden input field:

var x = document.getElementById("myInput").name;

亲自试一试

Example 2

Change the name of the hidden input field:

document.getElementById("myInput").name = "newName";

亲自试一试

语法

返回 name 属性:

hiddenObject.name

设置 name 属性:

hiddenObject.name = name

属性值

描述
name 规定隐藏输入字段的名称。

技术细节

返回值: 字符串值,表示隐藏输入字段的名称。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持