Skip to content

Instantly share code, notes, and snippets.

@EpokK
Created March 5, 2015 08:37
Show Gist options
  • Save EpokK/de8dc5d12306892b66e0 to your computer and use it in GitHub Desktop.
Save EpokK/de8dc5d12306892b66e0 to your computer and use it in GitHub Desktop.
Move Caret to End of Input or Textarea
var focus = function(input) {
if (typeof input.selectionStart === "number") {
input.selectionStart = input.selectionEnd = input.value.length;
} else if (typeof input.createTextRange !== "undefined") {
input.focus();
var range = input.createTextRange();
range.collapse(false);
range.select();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment