JSFiddle - React, Tailwind, and code Playground
by cfrings
HTML
<div id="testdiv">
Select some text inside this div and press Ctrl+C.
</div>
<div id="logdiv" style="border: 1pt solid black;"><p><i>Log</i></p></div>
JavaScript
$(function () {
$("#testdiv").on("copy", function(event) {
var sel = window.getSelection();
var $anchorNode = $(sel.anchorNode);
var $focusNode = $(sel.focusNode);
$("#logdiv").append("<p>The DOM nodes are" + (sel.anchorNode == sel.focusNode ? "" : "<b> not</b>") + " the same.</p>");
$("#logdiv").append("<p>The jQuery objects are" + ($anchorNode.is($focusNode) ? "" : "<b> not</b>") + " the same.</p>");
$("#logdiv").append("<p>Parent: the DOM nodes are" + (sel.anchorNode.parent == sel.focusNode.parent ? "" : "<b> not</b>") + " the same.</p>");
$("#logdiv").append("<p>Parent: the jQuery objects are" + ($anchorNode.parent().is($focusNode.parent() ) ? "" : "<b> not</b>") + " the same.</p>");
});
});