Automatic input field focus on page load
Sometimes you want an input field to be selected by default(automaticaly selected). Like when you go to google the search input field is automaticaly selected. We will do this in today’s daily tip using jQuery.
HTML
<input type='text' id='default_input' />
jQuery
$(document).ready(function() {
$('#default_input').focus();
});
Easy as that
Related posts:
- jQuery focus on first field trick
- Description text inside an input field
- Use HTML5 Placeholder Input Attribute Today using jQuery!
- Daily Tip : Difference between $(document).ready and $(window).load in jQuery
- Using multiple versions of jQuery on the same page
Slobodan Kustrimovic
This author has yet to fill his BIO.
Did you absolutely LOVE this article... share it!
Comments
Leave your own!