Latest web development tutorials

HTML DOM Input DatetimeLocal autofocus attribute

Input DatetimeLocal Object Reference Input DatetimeLocal objects

Examples

Check local time field whether to automatically get the focus when the page is loaded:

var x = document.getElementById("myLocalDate").autofocus;
x The output is:
true

try it"

Definition and Usage

autofocus property sets or returns the local time field whether to automatically get the focus when the page loads.

This property reflects the HTML autofocus property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus attribute.

Note: Internet Explorer 9 and earlier versions of IE, Opera 12 and earlier version of Opera browser does not support this property.

Note: Internet Explorer or Firefox browser does not support <input type = "datetime-local "> element.


grammar

Back autofocus properties:

datetimelocalObject .autofocus

Setting autofocus properties:

datetimelocalObject .autofocus=true|false

Property Value

描述
true|false 描述了本地时间字段在页面加载后是否获取焦点
  • true - 本地时间字段获取焦点
  • false - 默认。本地时间字段不获取焦点。

technical details

return value: Boolean field if the page automatically obtain the local time after loading the focus returns true, otherwise returns false.


Related Pages

HTML Reference Manual: HTML <the INPUT> The autofocus attribute


Input DatetimeLocal Object Reference Input DatetimeLocal objects