Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Email autofocus property

Input Email autofocus property

Input Email Object Reference Input Email Object

Example

Check whether the email field automatically gets focus after the page loads:

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

x

The output is:

true

Try it »


Definition and Usage

The autofocus property is used to set or return whether the email field automatically gets focus after the page loads.

This attribute reflects the HTML autofocus attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus attribute.

Note: Internet Explorer 9 and earlier versions, and Opera 12 and earlier versions, do not support this attribute.

Note: Internet Explorer 9 (and earlier IE versions) or Safari browser does not support the HTML element with type="email". .


Syntax

Return the autofocus attribute:

emailObject

.autofocus

Set the autofocus attribute:

emailObject

.autofocus=true|false

Attribute values

Value Description
true|false Describes whether the email field gets focus after the page loads
  • true - the email field gets focus
  • false - default. The email field does not get focus.
  • |

    Technical Details

    Return Value: Boolean, returns true if the email field automatically gets focus after loading, otherwise returns false.

    Related pages

    HTML Reference Manual: HTML autofocus attribute


    Input Email Object Reference Input Email Object