如何从这个后代中选择具有指定类的最后一个元素? [英] How do I select the last element with a specified class from descendants of this?
本文介绍了如何从这个后代中选择具有指定类的最后一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个< div>
,有许多< ul>
子类,调用此< div>
上的函数,该函数使用给定类修改最后的< ul>
。如何使用 $(this)
jQuery选择器选择最后一个< ul>
I have a <div>
with many <ul>
descendants with different classes, and I am calling a function on this <div>
which modifies the last <ul>
with a given class. How do I select the last <ul>
descendant with a specified class using $(this)
jQuery selector?
推荐答案
您可以使用 last
方法:
You can use the last
method:
var last = $(this).find("ul.someClass").last();
或 :last
selector:
Or the :last
selector:
var last = $(this).find("ul.someClass:last");
这篇关于如何从这个后代中选择具有指定类的最后一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文