Input Time name 属性

定义和用法

name 属性设置或返回时间字段的 name 属性的值。

HTML name 属性用于在表单数据提交到服务器后识别表单数据,或在客户端使用 JavaScript 引用表单数据。

Note:只有拥有 name 属性的表单元素才会在提交表单时传递它们的值。

另请参阅:

HTML 参考手册:HTML <input> name attribute

实例

例子 1

获取时间字段的名称:

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

亲自试一试

例子 2

更改时间字段的名称:

document.getElementById("myTime").name = "newTimeName";

亲自试一试

语法

返回 name 属性:

timeObject.name

设置 name 属性:

timeObject.name = name

Attribute value

Value Description
name Specifies the name of the time field.

Technical details

Return value: A string value representing the name of the time field.

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="time"> element does not display as any time field in Firefox.