Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
};
$(document).mouseup(function(){
console.log(getSelectedText());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.