Created
January 23, 2013 11:18
-
-
Save mertenvg/4604536 to your computer and use it in GitHub Desktop.
Set the selection to the contents of the specified DOM element.
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 select_contents(element) { | |
var selection = window.getSelection(); | |
var range = document.createRange(); | |
range.selectNodeContents(element); | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment