Created
October 31, 2012 18:08
-
-
Save ischenkodv/3988766 to your computer and use it in GitHub Desktop.
Move caret to the end of input or textarea
This file contains hidden or 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) { | |
if (typeof el.selectionStart == "number") { | |
el.selectionStart = el.selectionEnd = el.value.length; | |
} else if (typeof el.createTextRange != "undefined") { | |
el.focus(); | |
var range = el.createTextRange(); | |
range.collapse(false); | |
range.select(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment