Easy Tutorial
❮ Prop Option Index Prop Text Type ❯

Input Datetime autofocus Attribute

Input Datetime Object

Example

Check if the datetime field automatically gains focus after the page loads:

var x = document.getElementById("myDatetime").autofocus;
true

Definition and Usage

The autofocus attribute is used to set or return whether the datetime field automatically gains focus when the page loads.

This attribute reflects the HTML autofocus attribute.


Browser Support

All major browsers support the autofocus attribute.

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

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


Syntax

Return the autofocus attribute:

Set the autofocus attribute:

Attribute Values

Value Description
true false Describes whether the datetime field gains focus after the page loads. true - The datetime field gains focus. false - Default. The datetime field does not gain focus.

Technical Details

| Return Value: | Boolean, returns true if the datetime field automatically gains focus after the page loads, otherwise returns false. | | --- | --- |


Related Pages

HTML Reference: HTML <input> autofocus Attribute


❮ Prop Option Index Prop Text Type ❯