Input Button autofocus-eigenschap

Definitie en gebruik

autofocus Stel in of de invoerknop automatisch focus moet krijgen bij het laden van de pagina.

Deze eigenschap reflecteert de HTML autofocus-eigenschap.

Zie ook:

HTML Referentiemanual:HTML <input> autofocus attribute

Voorbeeld

Controleer of de knop automatisch focus krijgt bij het laden van de pagina:

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

Probeer het zelf

Syntax

Geef de autofocus-eigenschap terug:

buttonObject.autofocus

Stel de autofocus-eigenschap in:

buttonObject.autofocus = true|false

Eigenschapswaarde

Waarde Beschrijving
true|false

Specifies whether the input button should gain focus when the page is loaded.

  • true - the input button gains focus
  • false - default. The input button does not gain focus

Technical details

Return value: Boolean value, if the input button automatically gains focus when the page is loaded, it returns true, otherwise return false.

Browser support

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