Created
November 17, 2016 09:04
-
-
Save maxkostinevich/0aec581972b714d88f25f279f59c1791 to your computer and use it in GitHub Desktop.
JS 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
$('.element').on('mouseup', function(event){ | |
var selection; | |
if (window.getSelection) { | |
selection = window.getSelection(); | |
} else if (document.selection) { | |
selection = document.selection.createRange(); | |
} | |
selection.toString() !== '' && alert('"' + selection.toString() + '" was selected at ' + event.pageX + '/' + event.pageY); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment