Skip to content

Instantly share code, notes, and snippets.

@artygrand
Created September 14, 2017 05:40
Show Gist options
  • Save artygrand/364d6e8600609b86518590e8167a7d0a to your computer and use it in GitHub Desktop.
Save artygrand/364d6e8600609b86518590e8167a7d0a to your computer and use it in GitHub Desktop.
action on hovered text
var getSelectedText = function() {
var text = '';
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection) {
text = document.selection.createRange().text;
}
return text;
};
$('.should-highlit').on('mouseup', function(){
var text = getSelectedText();
if (text != ''){
alert('find and wrap it');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment