I need a way to identify all <p> tags between subheading tags <h2>as separated groups.
I can't use h2 ~ p as this selects all the <p> tags into a single selection.
I need to be able to stop the selection when another heading tag appears.
And the number of <p> tags will change so I doubt ::nth-child(x) will help, although I could be wrong.
<section>
<h2>Heading I want</h2>
<p>Some text I want</p>
<p>Some text I want</p>
<p>Some text I want</p>
<p>Some text I want</p>
<h2>Heading I don't want</h2>
<p>Text I don't want</p>
<p>Text I don't want</p>
<p>Text I don't want</p>
<p>Text I don't want</p>
</section>
Is this possible?
Update - Limitations:
Original structure can't be changed. The tool I'm using to export the text into data tables only has limited JS like commands that are as follows:
$e.text - gets the inner text or value
$e.outerHTML - get the outer html of the element
$e.prop - a function that behaves like jQuery prop function.
$e.css - a function that behaves like jQuery css function
$e.parentProp - a function that behaves like jQuery prop function.
$e.parent - get the parent element with all the same properties as $e/