Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 jquery 而不是选择器。我想要的是选择其中没有按钮类的“内容”类,然后选择跨度标记。我尝试了以下代码,但没有成功:
$(".content:not('.button') span");
我建议:
$(".content:not(:has('.button')) span");
或者:
$('.content').filter(function(){ return !$(this).find('.button').length; }).find('span');
使用:not(:has(selector)),这是一个工作示例:
:not(:has(selector))
jsFiddle
$(".content:not(:has(.button)) span");