Created
September 14, 2017 05:40
-
-
Save artygrand/364d6e8600609b86518590e8167a7d0a to your computer and use it in GitHub Desktop.
action on hovered text
This file contains hidden or 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 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