Latest web development tutorials

HTML DOM Input Date autofocus attribute

Input Date Object Reference Input Date Object

Examples

Check whether the date field automatically get the focus when the page is loaded:

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

try it"

Definition and Usage

autofocus attribute is used to set or return date field is automatically get the focus when the page loads.

This property reflects the HTML autofocus property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The autofocus property in all major browsers support

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 = "date"> element.


grammar

Back autofocus properties:

inputdateObject .autofocus

Setting autofocus properties:

inputdateObject .autofocus=true|false

Property Value

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

technical details

return value: Boolean value that, if the page date fields automatically get focus after loading returns true, otherwise returns false.


Related Pages

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


Input Date Object Reference Input Date Object