Skip to content

Instantly share code, notes, and snippets.

@andreruffert
Last active August 29, 2015 14:14
Show Gist options
  • Save andreruffert/7673c160dc490581c4ac to your computer and use it in GitHub Desktop.
Save andreruffert/7673c160dc490581c4ac to your computer and use it in GitHub Desktop.
Select all the content of an element. Supported in IE 9+
function selectContent(el) {
var range = document.createRange();
var selection = window.getSelection();
range.selectNodeContents(el);
selection.removeAllRanges();
selection.addRange(range);
}
var el = document.getElementById("elementId");
selectContent(el);
@deniztoprak
Copy link

Path Helper Demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment