Given this markup:
<div class="some_container">
<p>...</p>
<p>...</p>
<p>...</p>
<p>...</p>
<p>...</p>
<p>...</p>
<p>...</p>
</div>
Is there anyway for me to query for the parent of a collection in jQuery (or javascript) with a rule that basically means:
Return the parent element that contains 4 or more <p> tags
Or
Return a collection of all <p> tags with 4 or more siblings
… and then I can call .parent() on it?
I cannot simply search by the <div> since it is variable in my use case (different ids, classes, sometimes not even a <div> as the container). I need a way to find a group of related elements, then find the parent of that collection. Is this possible?
nth-of-type might be what you’re looking for. Something like:
That would grab a collection of elements that each have at least 4 paragraph elements.