JSFiddle - React, Tailwind, and code Playground
HTML
<div id="list">
<div class="good">first</div>
<div class="good">second</div>
<div>trash</div>
<div class="good">third</div>
</div>
JavaScript
function getIndex(obj) {
var $objectArray = $("#list").children(".good");
return $.inArray($(obj), $objectArray);
}
$(document).ready(function () {
$("#list").children(".good").click(function () {
var index = $("#list").children(".good").index(this);
alert(index);
});
});