jQuery/css目标第n个子类 固定标题1 一些内容 固定标题2 col4 div中没有的其他一些内容 col4 div中没有的其他一些内容

jQuery/css目标第n个子类 固定标题1 一些内容 固定标题2 col4 div中没有的其他一些内容 col4 div中没有的其他一些内容,jquery,css,jquery-selectors,css-selectors,Jquery,Css,Jquery Selectors,Css Selectors,大家好,这是我在这里的第一篇帖子——我很抱歉把我愚蠢的问题带到大家面前,但我自己很难解决这个问题 我想针对col4 div中没有其内容的div类“row”。 我尝试过使用cssnth-child,但这似乎不起作用,我也看过jQuery.find.has.filter,但我总是以最上面的.row或.row中的任何一行为目标 无论如何,我不能更改html,我只能使用javascript或css 请帮忙 非常感谢,, 达扎试试看 <div class="outercontainer">

大家好,这是我在这里的第一篇帖子——我很抱歉把我愚蠢的问题带到大家面前,但我自己很难解决这个问题

我想针对col4 div中没有其内容的div类“row”。 我尝试过使用cssnth-child,但这似乎不起作用,我也看过jQuery.find.has.filter,但我总是以最上面的.row或.row中的任何一行为目标

无论如何,我不能更改html,我只能使用javascript或css

请帮忙

非常感谢,, 达扎

试试看

<div class="outercontainer">
 <div class="paddedcontainer">

  <div class="pageheader">
   <div class="titlestyle"><h2>Fixed Title1</h2></div>
  </div>
  <div class="row">
   <div class="grouped">
    <div class="col4">
    Some content
    </div>
   </div>
  </div>

  <div class="pageheader">
   <div class="titlestyle"><h2>Fixed Title2</h2></div>
  </div>
  <div class="row">
  Some other content not in a col4 div
  </div>
  <div class="row">
  Some other content not in a col4 div
  </div>


 </div>
</div>
演示:

:用于从传递的集合中筛选出匹配的元素
:对于具有与传递的选择器匹配的元素的筛选元素,请使用和嵌套:

jQuery和否定组合在一起可以满足您的目的:

var rows = $('.row:not(:has(.col4))');

这可能适用于您的特定示例:

var $filtered = $(".row:not(:has(.col4))");

你的意思是你想把所有的div和class-row作为目标,而这些div没有一个孩子有class-col4吗?&事实会让你自由:)就是这样-你不知道这有多令人沮丧,你在一纳秒之内就解决了它。干杯@用户2519486如果您的问题已经解决,请接受此(an)答案。
var $filtered = $(".row:not(:has(.col4))");
var rows = $('.row').first().nextAll();