Input DatetimeLocal autofocusProperty

Input DatetimeLocal 对象参考手册Input DatetimeLocal Object

Examples

Check whether the local time field automatically gets focus after the page loads:

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

Try it Yourself »

Definition and Usage

The autofocus property is used to set or return whether the local time 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, Opera 12 and earlier Opera versions do not support this property.

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


Syntax

Return the autofocus property:

datetimelocalObject.autofocus

Set the autofocus property:

datetimelocalObject.autofocus=true|false

Property Values

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

Technical Details

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


Related Pages

HTML Reference Manual:HTML <input> autofocus attribute


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