Skip to content

Instantly share code, notes, and snippets.

@cmdoptesc
cmdoptesc / get-selected-text
Last active December 20, 2015 13:19
getSelectedText
var getSelectedText = function() {
var txt = "";
if (window.getSelection) {
txt = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
txt = document.selection.createRange().text;
}
return txt;
};