I need to know the position an item in HTML list.
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
</ul>
$('ul').on("click", function(event){
var target = event.target;
})
So when I get the first li
as the target of the event. How can I get 0
as result for the item postion. The only way I can think about is to iterate over all items and compare them with the event target, but I wonder if there is a better way to solve this.