Input Number autofocus Attribute

Definition and Usage

autofocus Attribute sets or returns whether the numeric field should be automatically focused when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:HTML <input> autofocus Attribute

Example

Determine whether the numeric field is automatically focused when the page is loaded:

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

Try it yourself

Syntax

Return autofocus attribute:

numberObject.autofocus

Set autofocus attribute:

numberObject.autofocus = true|false

attribute value

value description
true|false

Specifies whether the numeric field should gain focus when the page is loaded.

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

Technical Details

Return Value: Boolean value, returned if the numeric 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
Support 10.0 Support Support Support