Bbbb
1 | function selectText(element) { |
2 | // select the text |
3 | // thank you: http://stackoverflow.com/questions/18611992/selected-text-inside-div |
4 | var doc = document |
5 | , text = doc.getElementById(element) |
6 | , range, selection |
7 | ; |
8 | if (doc.body.createTextRange) { //ms |
9 | range = doc.body.createTextRange(); |
10 | range.moveToElementText(text); |
11 | range.select(); |
12 | } else if (window.getSelection) { //all others |
13 | selection = window.getSelection(); |
14 | range = doc.createRange(); |
15 | range.selectNodeContents(text); |
16 | selection.removeAllRanges(); |
17 | selection.addRange(range); |
18 | } |
19 | }; |
Comments
Post a Comment