jQuery:查找具有特定类的最后一个孩子 [英] jQuery: find a last child that has specific class

查看:74
本文介绍了jQuery:查找具有特定类的最后一个孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有深层嵌套的无序列表,并且有对根节点的引用,是否有一种内置方法来查找具有特定css类的"li"类型的最后一个子级?例如,如果我有一个树视图分支,深度为5级,并且分支向下扩展到第三级,则1,2,3级将具有可折叠"类.现在,在这种情况下,我想在第3级上找到具有此类的最后一个"li".

If I have deep nested unordered list and I have a reference to the root node, is there a built in way to find a last child of "li" type that has specific css class? For example if I have a tree view branch 5 levels deep, and branch is expanded down to thrid level, levels 1,2,3 will have a class "collapsable". Now I want to find a last "li" in this case on level 3 that has this class.

推荐答案

不太难:

$("li.someclass", rootOfList).last()

在类someclass

这篇关于jQuery:查找具有特定类的最后一个孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆