Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  187] [ 4]  / answers: 1 / hits: 23841  / 12 Years ago, thu, january 17, 2013, 12:00:00

Possible Duplicate:

How to set the focus to the first input element in an HTML form independent from the id?






I'm using BootStrap with ASP.NET MVC4. There is one login form but I'm unable to set focus on first input field.



How to set focus on first field of input? Is there any BootStrap class that uses to set focus?


More From » html

 Answers
20

There isn't a Bootstrap-specific class or function that does this*, but HTML5 provides the autofocus attribute for input fields.



This attribute currently enjoys wide browser support.



*-Since you are using Bootsrap, and Bootstrap is powered by jQuery, you could shim older browsers that otherwise don't support autofocus:



$('[autofocus]:first').focus();

[#80803] Wednesday, January 16, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shamya

Total Points: 38
Total Questions: 101
Total Answers: 96

Location: Thailand
Member since Thu, Apr 22, 2021
3 Years ago
;