JSFiddle - React, Tailwind, and code Playground
HTML
<div id="or">
<p>hello</p>
</div>
<div id="di"> <span id="sp">
<p id="pp">world</p>
</span>
<span id="spa">
<img src="http://jsfiddle.net/img/logo.png" style="background: #4679bd;" />
</span>
</div>
<div id="out">
<p>test</p>
</div>
CSS
p#pp {
pointer-events: none;
-webkit-user-select: none;
}
#sp {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
JavaScript
$('div#di').on('click', 'span', function () {
$('div#out p').text(window.getSelection().toString());
});