in the div container I want to select and group all the headers with its contents until the next heading. These blocks should have a different background color.
This is what I got in my html:
<div class="container">
<h2></h2>
<p></p>
<p></p>
<ul></ul>
<h2></h2>
<p></p>
<p></p>
<p></p>
<h2></h2>
<p></p>
<p></p>
<p></p>
</div>
And I need this:
<div class="container">
<div class="xy">
<h2></h2>
<p></p>
<p></p>
<ul></ul>
</div>
<div class="xy">
<h2></h2>
<p></p>
<p></p>
<p></p>
</div>
<div class="xy">
<h2></h2>
<p></p>
<p></p>
<p></p>
</div>
</div>
I tried using nextUntil (), but so far this has not worked.
I would appreciate any help.
Best Robin
source
share