Created
May 15, 2014 20:13
-
-
Save eloone/77c702bde112a0758763 to your computer and use it in GitHub Desktop.
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
var range = document.createRange();//Create a range (a range is a like the selection but invisible) | |
range.selectNodeContents(this.target);//Select the entire contents of the element with the range | |
range.setEnd(this.target.firstChild, pos); | |
range.collapse();//collapse the range to the end point. false means collapse to end rather than the start | |
selection = window.getSelection();//get the selection object (allows you to change selection) | |
selection.removeAllRanges();//remove any selections already made | |
selection.addRange(range); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment