I'm trying to select all h3 tags under h2 tags even if into li whether ul or ol in a page, using .nextUntil().
HTML markup is like:
<h2></h2>
<h3></h3>
<h3></h3>
<h3></h3>
<h2></h2>
<h3></h3>
<h3></h3>
<h3></h3>
<h2></h2>
<ol>
<li>
<h3></h3>
</li>
<li>
<h3></h3>
</li>
<li>
<h3></h3>
</li>
</ol>
Js is like:
var h2s = $('h2').toArray();
var h3s = [];
for (i = 0, i < h2s.length, i++){
h3s.push($('h2').eq(i).nextUntil('h2', 'h3, li h3').toArray());
};
console.log(h3s);
The expected output is:
h3s[
0: (3) [h3, h3, h3]
1: (3) [h3, h3, h3]
2: (3) [h3, h3, h3]
]
While the real output is:
h3s[
0: (3) [h3, h3, h3]
1: (3) [h3, h3, h3]
2: []
]