Skip to content

Instantly share code, notes, and snippets.

@othree
Created August 24, 2009 17:09
Show Gist options
  • Save othree/173967 to your computer and use it in GitHub Desktop.
Save othree/173967 to your computer and use it in GitHub Desktop.
function moveLast(target) {
if (target.nodeName.toLowerCase() != 'input' || target.type != 'text') return false;
var pos = target.value.length;
target.focus();
if (target.createTextRange) {
var range = target.createTextRange();
range.move("character", pos);
range.select();
} else if (target.setSelectionRange) {
target.setSelectionRange(pos, pos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment