Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.