Input Email autofocus attribute

Definition and usage

autofocus Attribute setting or returning 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 egenskab

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 supports

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Understøtter Understøtter Understøtter Understøtter Understøtter

Alle større browsere understøtter autofocus Egenskaber.

Bemærk:Internet Explorer 9 og tidligere versioner eller Opera 12 og tidligere versioner understøtter ikke autofocus Egenskaber.

Bemærk:Internet Explorer 9 og tidligere versioner eller Safari understøtter ikke <input type="email"> elementet.