Is there a generic way in jQuery or JavaScript (most cross-browser compatible) to check if text has been highlighted?
I am working with an HTML
You can use the Selection object :
var selection = window.getSelection();
See the documentation here : https://developer.mozilla.org/en-US/docs/Web/API/Selection
With this object, you can check the selected dom node (anchorNode). For example :
if ($(window.getSelection().anchorNode).attr('id') === 'something') { ... }