Input Number autofocusProperty

Input Number 对象参考手册Input Number Object

Examples

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

var x = document.getElementById("myNumber").autofocus;
xOutput result:
true

Try it Yourself »

Definition and Usage

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

This property reflects the HTML autofocus attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus property.

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

Note:Internet Explorer 9 and earlier IE versions do not support <input> elements with type="number" attribute.


Syntax

Return the autofocus property:

numberObject.autofocus

Set the autofocus property:

numberObject.autofocus=true|false

Property Values

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

Technical Details

Return Value: A Boolean, returning true if the number field automatically gets focus after the page loads, otherwise returns false.


Related Pages

HTML Reference:HTML <input> autofocus attribute


Input Number 对象参考手册Input Number Object Other Extensions