Input Search autofocus eigenschap

Definitie en gebruik

autofocus Eigenschap instellen of teruggeven of het zoekveld automatisch focus krijgt bij het laden van de pagina.

Deze eigenschap reflecteert de HTML autofocus eigenschap.

Zie ook:

HTML Referentie Handboek:HTML <input> autofocus attribute

Voorbeeld

Vind uit of het zoekveld automatisch focus krijgt bij het laden van de pagina:

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

Probeer het zelf

Syntax

Geef de autofocus-eigenschap terug:

searchObject.autofocus

Stel de autofocus-eigenschap in:

searchObject.autofocus = true|false

Eigenschapswaarde

Waarde Beschrijving
true|false

Regel of de zoekveld moet de focus krijgen bij het laden van de pagina.

  • true - the search field gets focus
  • false - default. The search field does not get focus

Technical details

Return value: Boolean value, if the search field automatically gets focus when the page is loaded, it returns true; otherwise return false.

Browser support

The numbers in the table indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support