Select autofocus attribute
Definition and usage
autofocus
The attribute setting or returning whether the dropdown list should automatically gain focus when the page is loaded.
This attribute reflects HTML autofocus attribute.
See also:
HTML Reference Manual:HTML <select> Tag
Example
Determine whether the dropdown list will automatically gain focus when the page is loaded:
var x = document.getElementById("mySelect").autofocus;
Syntax
Return autofocus attribute:
selectObject.autofocus
Set autofocus attribute:
selectObject.autofocus = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specify whether the dropdown list should gain focus when the page is loaded.
|
Technical Details
Return Value: | Boolean value, returns true if the dropdown list automatically focuses on page load; otherwise returns false. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <select> autofocus Attribute