Created
April 3, 2015 07:25
-
-
Save JoeKeikun/aab8c5874fd4720c3988 to your computer and use it in GitHub Desktop.
get selected text
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
$('div').mouseup(function() { | |
alert(getSelectedText()); | |
}); | |
function getSelectedText() { | |
if (window.getSelection) { | |
return window.getSelection().toString(); | |
} else if (document.selection) { | |
return document.selection.createRange().text; | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment