Input Email autofocus Attribute

Definition and Usage

autofocus Sets or returns whether the email field should automatically gain focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See Also:

HTML Reference Manual:HTML <input> autofocus-Attribut

Example

Determine if the email field automatically gains focus when the page is loaded:

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

Try It Yourself

Syntax

Return autofocus attribute:

emailObject.autofocus

Set autofocus attribute:

emailObject.autofocus = "true|false"

Attribute Value

Value Description
true|false

Specifies whether the email field should gain focus when the page is loaded

  • true - The email field gains focus
  • false - Default. The email field does not gain focus

Technical Details

Return value: Boolean value, returned if the email field automatically gains focus when the page is loaded true;otherwise return false

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Unterstützt Unterstützt Unterstützt Unterstützt Unterstützt

Alle主要浏览器 unterstützen dies autofocus Eigenschaften.

Anmerkung:Internet Explorer 9 und frühere Versionen oder Opera 12 und frühere Versionen unterstützen dies nicht autofocus Eigenschaften.

Anmerkung:Internet Explorer 9 und frühere Versionen oder Safari unterstützen das <input type="email">-Element nicht.