Input Datetime autofocus attribute

Definition and usage

autofocus Attribute sets or returns whether the date and time field should be automatically focused when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:Atribut autofocus <input> HTML

Example

Find out if the date and time field is automatically focused when the page is loaded:

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

Try it yourself

Syntax

Return autofocus attribute:

datetimeObject.autofocus

Set autofocus attribute:

datetimeObject.autofocus = true|false

Attribute value

Value Description
true|false

Specify whether the date and time field should receive focus when the page is loaded.

  • true - The date and time field receives focus
  • false - Default. The date and time field does not receive focus

Technical details

Return value: Boolean value, if the date and time field is automatically focused when the page is loaded, it returns trueatau kembali false.

Pendukung pelayar

Nombor di dalam jadual menunjukkan versi paling awal yang menyokong sifat ini.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Dipendukung 10.0 Dipendukung Dipendukung Dipendukung

Perhatian:Elemen <input type="datetime"> tidak menunjukkan mana-mana medan tarikh dan masa kalender di luar Safari.