Is there any attribute for select tag in HTML like autoFocus for textbox ? So that select should have default focused. Means I want to do autofocus for select tag.
Asked
Active
Viewed 1,491 times
0
-
Possible duplicate of http://stackoverflow.com/questions/4166423/default-html-form-focus-without-javascript. – Anders Aug 21 '15 at 09:47
1 Answers
1
You can use autofocus
in the select tag as follows:
<select autofocus>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
If you run the code snippet and then immediately press enter or the down arrow then you will see that the select has the focus on the page. Is this what you wanted?

tombarti
- 426
- 2
- 8
-
autofocus did not work with select tag, it works good with text. – JavaScript Linq Aug 21 '15 at 09:55
-
-
Sorry autofocus attribute is for input tag not for select tag. – JavaScript Linq Aug 24 '15 at 10:57