JQuery / script cheatsheet
Revision as of 11:18, 6 September 2017 by old>Admin (→Selecting text for easy copying)
Selecting text for easy copying
var textNode = document.getElementById('IdOfNodeToBeSelected'); 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); }