JQuery / script cheatsheet

From TempusServa wiki
Revision as of 11:17, 6 September 2017 by old>Admin (Created page with " ==== Selecting text for easy copying ==== var textNode = document.getElementById('opusNode'); if (document.selection) { var range = document.body.createTextRange();...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Selecting text for easy copying

 var textNode = document.getElementById('opusNode');
 if (document.selection) {
   var range = document.body.createTextRange();
   range.moveToElementText(textNode);
   range.select();
 } else if (window.getSelection) {
   var selection = window.getSelection();
   var range = document.createRange();
   range.selectNodeContents(textNode);
   selection.removeAllRanges();
   selection.addRange(range);	
 }