Easy Tutorial
❮ Prop Anchor Href Prop Fileupload Form ❯

Input Search autofocus Attribute

Input Search Object

Example

Check if the search field automatically gains focus after the page loads:

var x = document.getElementById("mySearch").autofocus;
true

Definition and Usage

The autofocus attribute is used to set or return whether the search field should automatically get focus when the page loads.

This attribute reflects the HTML autofocus attribute.


Browser Support

All major browsers support the autofocus attribute.

Note: Internet Explorer 9 and earlier versions or Opera 12 and earlier versions do not support the autofocus attribute.


Syntax

Return the autofocus attribute:

Set the autofocus attribute:

Attribute Values

Value Description
true false Describes whether the search field gains focus after the page loads. true - The search field gains focus. false - Default. The search field does not gain focus.

Technical Details

| Return Value: | Boolean, returns true if the search field automatically gains focus after the page loads, otherwise returns false. | | --- | --- |


Related Pages

HTML Reference: HTML <input> autofocus Attribute


❮ Prop Anchor Href Prop Fileupload Form ❯