Let's say I am working with an unordered list like this one:
<ul>
<li class="item"></li>
<li class="item"></li>
<li class="item"></li>
<li class="placeholder"></li>
</ul>
As part of my ordering process, I need to sort the .item
elements and if the last one is in the list, move it to a different list. Normally, I would use :last-child
for selecting the last item. However, when there is a .placeholder
, the selection gets confused by it and doesn't recognize the actual last item correctly. How can I ensure that only the last .item
is selected?