how to select ul li in jQuery
i have a ul li in jQuery and i want to select last li from the ul i make like
<ul>
<!-- many li here --->
<li><a id="nqp2" class="apager" href="/2">
next</a></li>
</ul>
how to select last div here without using :last in jQuery
the following thing can be used :>
the id starting from char "n" like they always have id starting from "n" and all other not have these char starting from.
the last li i want to select always have wor开发者_高级运维d next inside them.
are their any way to select li using any way of these two selection pattern
Using your first method:
$('li:has(a[id^="n"])')
Using your second method:
$('li:contains("next")')
With jQuery you can use classes and ids to select elements, same as CSS. In this case your last li has a class so:
$function (){
$(".apager")... (rest of your jQuery)
It's best to always add a class or id if you'll be selecting it with jQuery/CSS :)
Jquery selector: $('ul li:last-child')
精彩评论