JSFiddle - React, Tailwind, and code Playground

HTML

<div id="list">
    <div>first</div>
    <div>second</div>
    <div>third</div>
</div>

JavaScript

function getIndex(obj) {
    var $objectArray = $("#list").children();
    return $.inArray($(obj), $objectArray);
}

$(document).ready(function () {
    $("#list").children().click(function () {
        var index = getIndex(this);
        alert(index);
    });
});