Consider the following HTML - a classic grid system:
<div class="container">
<div>
<div class="grid">
<div>
<ul class="row">
<li class="grid"></li>
</ul>
</div>
</div>
</div>
</div>
A section always starts with a .container
The first .grid
in the hierarchy is not preceeded by a .row
The second, third... .grid elements are always divided by a .row
.
A .grid
is always a descendant of a container, but not guaranteed to be the first direct descendant.
A .row
is always a descendant of a .grid
, but not guaranteed to be the first direct descendant.
A child .grid
is always a descendant of a .row
, but not guaranteed to be the first direct descendant.
I want to find the first .grid
element below a .container
(the first in the branch). If there are multiple branches I want to select all of them. The .grid
element is never preceeded by a .row
- any advice?