jQuery focus on first field trick
I have developed quite a few Web Apps and something that I have always found useful is the ability to pre-select the first input field on the page so it’s easy for the user to start filling out a form.
I have developed quite a few Web Apps and something that I have always found useful is the ability to pre-select the first input field on the page so it’s easy for the user to start filling out a form.
So without further ado here is my little trick that will automatically work for any situation!
$(document).ready(function(){
$("input[type=text]:first").focus();
});
Pretty nifty little “plugin”. I’m sure you guys can use this in all kinds of situations!
Enjoy!
Related posts:
- Automatic input field focus on page load
- Use HTML5 Placeholder Input Attribute Today using jQuery!
- Description text inside an input field
- Advanced jQuery Placeholder Plugin (cross-browser support)
- How To Create a jQuery Plugin
Did you absolutely LOVE this article... share it!
Comments
Quite and simple, but very useful trick. Thanks!
Nice solution but i think it’s more convenient to simply use tabindex; here you have quick explanation http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html
Leave your own!