Input Datetime autofocusProperty

Input Datetime 对象参考手册Input Datetime Object

Examples

Check whether the datetime field automatically gets focus after the page loads:

var x = document.getElementById("myDatetime").autofocus;
xThe result is:
true

Try it Yourself »

Definition and Usage

The autofocus property is used to set or return whether a datetime field automatically gets focus after the page loads.

This property reflects the HTML autofocus attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus property.

Note:Internet Explorer 9 and earlier IE versions, and Opera 12 and earlier Opera versions do not support this property.

Note:Internet Explorer or Firefox browsers do not support the <input type="date"> element.


Syntax

Return the autofocus property:

datetimeObject.autofocus

Set the autofocus property:

datetimeObject.autofocus=true|false

Property Values

Value Description
true|false Describes whether the datetime field gets focus after the page loads.
  • true - The datetime field gets focus
  • false - Default. The datetime field does not get focus.

Technical Details

Return Value: A Boolean, returning true if the datetime field automatically gets focus after the page loads, otherwise returns false.


Related Pages

HTML Reference:HTML <input> autofocus Attribute


Input Datetime 对象参考手册Input Datetime Object Other Extensions