Input Reset autofocus Attribute

Definition and Usage

autofocus The attribute sets or returns whether the reset button should automatically receive focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:HTML <input> autofocus Attribute

Example

Check if the reset button will automatically receive focus when the page is loaded:

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

Try it yourself

Syntax

Return the autofocus attribute:

resetObject.autofocus

Set the autofocus attribute:

resetObject.autofocus = true|false

Attribute value

Value Description
true|false

Specify whether the reset button should receive focus when the page is loaded.

  • true - The reset button gains focus
  • false - Default. The reset button does not gain focus

Technical Details

Return Value: Boolean value, returned if the reset button automatically gains focus when the page is loaded. true; otherwise return false.

Browser Support

The numbers in the table indicate the first browser version to fully support this attribute.

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