Created
July 4, 2018 12:39
-
-
Save web2ls/d56d5bb8c9db91582f60cf72c770ad5b to your computer and use it in GitHub Desktop.
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 setInputSelection(input, startPos, endPos) { | |
| if (input.setSelectionRange) { | |
| input.focus(); | |
| input.setSelectionRange(startPos, endPos); | |
| } else if (input.createTextRange) { | |
| var range = input.createTextRange(); | |
| range.collapse(true); | |
| range.moveEnd('character', endPos); | |
| range.moveStart('character', startPos); | |
| range.select(); | |
| } | |
| } | |
| function setInputPos(input, pos) { | |
| setInputSelection(input, pos, pos); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment