What this does is triggering an event when text is selected in the document, and returning the selected text plus the nearest element containing all the text. What this means is that if a text selection spans over several elements, e.g. <strong>, <strike> etc, it'll select the parent, as that DOM element is containing all the text that has been selected.
Please note, as of now, it doesn't support multi text selections in Webkit/Firefox.
$(document).bind('textselect', function (evt, string, element) { if (string != "") alert('Selected text (' + element.tagName + '): ' + string); });