Textarea autofocus attribute

Definition and Usage

autofocus Attribute setting or returning whether the text area should automatically gain focus when the page is loaded.

This attribute reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:HTML <input> autofocus attribute

Example

Determine whether the text area automatically gains focus when the page is loaded:

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

Try it yourself

Syntax

Return the autofocus attribute:

textareaObject.autofocus

Set the autofocus attribute:

textareaObject.autofocus = true|false

attribute value

value description
true|false

Définit si le champ de texte doit obtenir le focus au chargement de la page.

  • true - le champ de texte obtient le focus
  • false - par défaut. Le champ de texte n'obtient pas le focus

Détails techniques

Valeur de retour : Valeur booléenne, retourne si le champ de texte doit obtenir le focus automatiquement au chargement de la page true;sinon retourne false.

Support du navigateur

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