Input Number autofocus
Attribute
Example
Check if the number field automatically gains focus when the page loads:
Definition and Usage
The autofocus
attribute is used to set or return whether the number field should automatically gain 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, and Opera 12 and earlier versions do not support this attribute.
Note: Internet Explorer 9 and earlier versions do not support the <input>
element with the type="number"
attribute.
Syntax
Return the autofocus
attribute:
Set the autofocus
attribute:
Attribute Values
Value | Description | |
---|---|---|
true | false | Specifies whether the number field gains focus when the page loads. <br> true - The number field gains focus. <br> false - Default. The number field does not gain focus. |
Technical Details
| Return Value: | Boolean, returns true if the number field automatically gains focus when the page loads, otherwise returns false. | | --- | --- |
Related Pages
HTML Reference: HTML <input>
autofocus Attribute