Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input DatetimeLocal autofocus attribute

Input DatetimeLocal autofocus attribute

Input DatetimeLocal Object Reference Input DatetimeLocal Object

Example

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

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

x

The output is:

true

Try it »


Definition and Usage

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

This attribute reflects the HTML autofocus attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 or Firefox browser does not support .


Syntax

Return the autofocus attribute:

datetimelocalObject

.autofocus

Set the autofocus attribute:

datetimelocalObject

.autofocus=true|false

Attribute values

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

    Technical Details

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

    Related pages

    HTML Reference Manual: HTML autofocus attribute


    Input DatetimeLocal Object Reference Input DatetimeLocal Object