I need to select the ul
parent of the li
element being clicked. But as a li
stays within the other the javascript understands that I am clicking on li
and all li
pais.
<ul class="lista">
<li class="item">
Pai
<ul class="lista">
<li class="item">
Filho
<ul class="lista">
<li class="item">Neto 1</li>
<li class="item">Neto 2</li>
</ul>
</li>
<ul>
</li>
</ul>
I've already tried a thousand ways to make the selection of ul
, but I ended up deleting the code and I just got a little debug code:
$(document).ready(function () {
$(document).on('click','.item:last-child', function () {
alert($(this).parent().length);
});
});
Only when I made this code I was able to see that js understands that I clicked on all the hierarchies of the li and not only on the clicked, even with this.