Skip to content

Instantly share code, notes, and snippets.

@Murmurianez
Last active August 29, 2015 14:13
Show Gist options
  • Save Murmurianez/23f22ca3c3890529fb9f to your computer and use it in GitHub Desktop.
Save Murmurianez/23f22ca3c3890529fb9f to your computer and use it in GitHub Desktop.
Set cursor position at end of input
$('[type="text"]').focus(function(){
var element = $(this)[0];
if (this.setSelectionRange) {
var len = $(this).val().length * 2;
element.setSelectionRange(len, len);
}else {
$(this).val($(this).val());
$(this).focus();
}
element.scrollTop = 9999;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment