Given the following markup
<ul class="list">
<li>first item</li>
<li class="item">second item</li>
<li>third item</li>
</ul>
Which one these 2 expressions is better to select the second li?
$("ul li.item")
or
$("ul li").filter(".item")
This is not a very good example because it's too simple (I know I could be doing $(".item")
, but in general, should I be using complex selectors or the filter function?
EDIT: If the first is more efficient, when is it appropriate / best to use the filter function?