jQuery选择器-其中项目没有特定类的子级 [英] jQuery Selectors - where item does not have children with a certain class
本文介绍了jQuery选择器-其中项目没有特定类的子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想选择#nav的直属子项,而列表项本身不具有'active'类别的直子.
I want to select list items that are immediate children of #nav, that do not themselves have immediate children with an 'active' class.
这是我认为应该的,但它不起作用:
This is what I think it should be but it does not work:
$('#nav > li:not(> a.active)')
推荐答案
您将需要使用jQuery的filter
函数:
You'll need to use jQuery's filter
function:
$('#nav > li').filter(function() { return !($(this).children().is('.active')); })
这篇关于jQuery选择器-其中项目没有特定类的子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文