Suppose you have the following setup (the numbers are there just for reference):
const html = `
<div 1>
<div>...</div>
<div 2>...</div>
<div>...</div>
...
</div>`;
$ = cheerio.load(html, null, false);
The three dots can also contain nested divs and other html!
How would I select the div 1? I tried
$(':scope') -> null
$('>div') -> null
For some reason I cannot select the first/root div.
But even if that makes sense, how would you select its direct children (div 2). I tried
$(':scope>div') -> null
$().children().eq(1) -> null
$(':scope').children().eq(1) -> null
I get the impression :scope
does not do what I think it does. Any suggestions?