I’m trying to get all the elements on a page which have multiple divs as child elements. For example, in the following code:
<div id="1">
<div id="1a">
<div id="1aa">
</div>
<div id="1ab">
</div>
</div>
<div id="1b">
</div>
</div>
<div id="2">
<div id="2b">
</div>
</div>
My function would return #1 and #1a as they both contain 2 child divs.
I’ve tried this:
$('div > div + div').css("border", "1px solid red");
But not only does this not work as desired, I also want it to apply when there are 5, 6, 7 /as many as possible child divs, provided it is >=2.
What’s the best way to achieve this?
You can use
.filter().