JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>Item 1</li>
<li><a href = "#">Link 1</a></li>
</ul>
<ul>
<ul>
<li>L2I1</li>
<li>L2I2</li>
</ul>
<li>Last Item</li>
</ul>
JavaScript
var all = document.getElementsByTagName('*');
for (var i = 0; i < all.length; i++)
all[i].onclick = function(e) {
window.selectedElement = this;
((e && e.stopPropagation && e.stopPropagation()) ||
(window.event && (window.event.cancelBubble = true)));
return false;
}