I would like to know the index of the li elements, just which has a certain class.
<ul>
<li style="display: none;">don't need this one</li>
<li class="li">sdsds</li>
<li class="li">sdsds</li>
<li class="li">sdsds</li>
</ul>
$('ul').each(function () {
$(this).on('click', 'li.li', function () {
alert($(this).index());
});
});
http://jsfiddle.net/oobkzyat/2/
My problem is that the index is not starting with 0. How can I do it?
data-attribute, or... etc.