Rather than use $('.list').find('li:not(.done):last')
, which returns all LI
that is not .done
and is the last of every .list
, how can I use functions instead?
For instance, $('.list').find('li').not('.done').last()
would return just one item, because it searches all .list
for LI
that aren't .done
and then just returns the last one.
There are a few reasons I want to do this. Primarily, typically using functions are faster than CSS selectors (in some cases, especially when you split them up into multiple functions as jQuery doesn't have to manually split up the selectors, and oftentimes jQuery functions are just mapped directly to existing CSS selectors anyway). But anyway, curiosity is my main reason at the moment, and performance is secondary.
Sample code (not entirely representative of the actual code, but the structure is similar):
<ul class="list">
<li>One</li>
<li class="done">Two</li>
</ul>
<ul class="list">
<li class="done">Three</li>
<li>Four</li>
</ul>
I want to return the nodes for:
One
and Four
.