User Tim Down of the Stack Overflow forum provided a very simple Javascript code to clear selected text. This should work in all major browsers.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function clearSelectedText() { if (window.getSelection) { if (window.getSelection().empty) { // Chrome window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { // Firefox window.getSelection().removeAllRanges(); } } else if (document.selection) { // IE? document.selection.empty(); } } |