Posts

Showing posts from May, 2014

jQuery auto-focus on particular text field after page load

Below code will help us to focus on particular text field in page. It will be used for users to start typing their queries after page is loaded. We can use this in login, search pages etc., for quick access. jQuery(document).ready(function() { var txtField = jQuery("#autocomplete").get(0); var elemLen = txtField.value.length; txtField.selectionStart = elemLen; txtField.selectionEnd = elemLen; txtField.focus(); });