Input Time autofocus Attribute

Definition and Usage

autofocus Property to set or return whether the time field should automatically gain focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See Also:

HTML Reference Manual:HTML <input> autofocus Attribute

Example

Find out if the time field automatically gains focus when the page is loaded:

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

Try It Yourself

Syntax

Return autofocus attribute:

timeObject.autofocus

Set autofocus attribute:

timeObject.autofocus = true|false

Attribute Value

Value Description
true|false

Specifies whether the time field should gain focus when the page is loaded.

  • true - The time field has gained focus.
  • false - Default. The time field has not gained focus.

Technical Details

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

Browser Support

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