Last active
December 20, 2015 13:19
-
-
Save cmdoptesc/6137770 to your computer and use it in GitHub Desktop.
getSelectedText
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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