Created
May 9, 2017 06:31
-
-
Save di3/140154084dd4e1872137c943d7c598ec to your computer and use it in GitHub Desktop.
select text javascript
This file contains hidden or 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
//select text inside element | |
function selectText(e){ | |
var t,n,o=document,a=window,c=o.body,l="unbdefined"; | |
typeof a.getSelection!=l&&typeof o.createRange!=l?(n=o.createRange(),n.selectNodeContents(e),t=a.getSelection(),t.removeAllRanges(),t.addRange(n)) : typeof o.selection!=l&&typeof c.createTextRange!=l&&(n=c.createTextRange(),n.moveToElementText(e),n.select()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment