Skip to content

Instantly share code, notes, and snippets.

@garystorey
Created July 21, 2017 16:27
Show Gist options
  • Select an option

  • Save garystorey/01074fd1d48f425104772b8a6e458b4e to your computer and use it in GitHub Desktop.

Select an option

Save garystorey/01074fd1d48f425104772b8a6e458b4e to your computer and use it in GitHub Desktop.
function selectText(e,r,s,d) {
d = document;
if (s = window.getSelection) {
(r = d.createRange()).selectNode(e);
(s = s()).removeAllRanges();
s.addRange(r);
}
else if (d.selection) {
(r = d.body.createTextRange()).moveToElementText(e);
r.select();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment