I am facing a challenge with an HTML structure containing multiple instances of a certain element along with two p
elements beneath each:
<some_tag></some_tag>
<p></p>
<p></p>
<some_tag></some_tag>
<p></p>
<p></p>
<some_tag></some_tag>
<p></p>
<p></p>
In my actual scenario, I have more than just three sets of structures (closer to thirty) and I require automation for the task.
The specific requirement is to target the last p
in the first two structures, excluding the last p
in the final structure.
The Issue at Hand
Unfortunately, there appears to be no straightforward CSS approach to achieve this desired selection.
Exploring the possibility of wrapping each non-last instance of the some_tag
within another element (such as a div
), I find this solution unattractive from an aesthetic standpoint.
My Inquiry
Is there a way to automate the specified selection using JavaScript?