Created
July 16, 2013 22:55
-
-
Save luis-almeida/6015967 to your computer and use it in GitHub Desktop.
Move Cursor To End of Textarea or Input.
Vanilla JS for http://css-tricks.com/snippets/jquery/move-cursor-to-end-of-textarea-or-input/?utm_source=dlvr.it&utm_medium=twitter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function moveCursorToEnd(el) { | |
el.focus(); | |
if (el.setSelectionRange) { | |
var len = el.value.length * 2; | |
el.setSelectionRange(len, len); | |
} else el.value = el.value; | |
el.scrollTop = 999999; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working on Chrome