JSFiddle - React, Tailwind, and code Playground

HTML

<ul>
    <li>a
        <li>b
            <li>c</ul>

JavaScript

document.getElementsByTagName("ul")[0].onclick = function (e) {
    var el = e.target;
    while (el != document.body && el.tagName.toLowerCase() != "li") {
        el = el.parentNode;
    }
    alert([].indexOf.call(el.parentNode.children, el));
}