The last example of jQuery\'s focus() documentation states
$(\'#id\').focus()
should make the input focused (active). I can\'t seem to get
Add a delay before focus(). 200 ms is enough
function focusAndCursor(selector){ var input = $(selector); setTimeout(function() { // this focus on last character if input isn't empty tmp = input.val(); input.focus().val("").blur().focus().val(tmp); }, 200); }