Latest web development tutorials

HTML DOM Input Datetime autofocus attribute

Input Datetime Object Reference Input Datetime Object

Examples

Check whether datetime fields automatically get the focus when the page is loaded:

var x = document.getElementById ( "myDatetime") autofocus.;
x The output is:
true

try it"

Definition and Usage

autofocus property sets or returns datetime field whether to automatically get the focus when the page loads.

This property reflects the HTML autofocus property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus attribute.

Note: Internet Explorer 9 and earlier versions of IE, Opera 12 and earlier version of Opera browser does not support this property.

Note: Internet Explorer or Firefox browser does not support <input type = "date"> element.


grammar

Back autofocus properties:

datetimeObject .autofocus

Setting autofocus properties:

datetimeObject .autofocus = true | false

Property Value

value description
true | false It describes the datetime field if gets focus after the page loads
  • true - datetime field gets focus
  • false - default. datetime field does not get the focus.

technical details

return value: Boolean value that, if the page datetime fields automatically get focus after loading returns true, otherwise returns false.


Related Pages

HTML Reference Manual: HTML <the INPUT> The autofocus attribute


Input Datetime Object Reference Input Datetime Object