Input Time autofocus 属性

定义和用法

autofocus 属性设置或返回时间字段是否应在页面加载时自动获得焦点。

此属性反映 HTML autofocus 属性。

另请参阅:

HTML 参考手册:HTML <input> autofocus Attribute

实例

查明时间字段是否在页面加载时自动获得焦点:

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

亲自试一试

语法

返回 autofocus 属性:

timeObject.autofocus

设置 autofocus 属性:

timeObject.autofocus = true|false

属性值

描述
true|false

规定页面加载时时间字段是否应获得焦点。

  • true - 时间字段获得焦点
  • false - 默认。时间字段未获得焦点

技术細節

Return value: Boolean value, returns if the time field automatically focuses when the page is loaded true, otherwise return false.

Browser Support

The numbers in the table indicate the first browser version to fully support 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.