You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//test.js
'use strict';
import * as cheerio from 'cheerio'
const $root = cheerio.load(`
<div class="foo">
This is my text
</div>
<div class="foo">
<div class="bar">
this is more text
</div>
</div>`);
console.log($root.text());
console.log($root.html());
const $sub = $root('.foo');
console.log($sub.text());
console.log($sub.html());
console.log($root.find('.bar')); //$root.find is not a function
$root('.foo').each(
(i, $foo) => {
console.log(`${i} ${$foo.html()}`); // $foo.html is not a function
console.log(`${i} ${$foo.text()}`); // $foo.text is not a function
}
)
The docs at do not show any examples of using select result instances of cheerio. Nor do they articulate how this object differs from the root.
They say find() is available, but it doesn't work for me.
The function .each(), though it works, is nowhere in the docs that I could find either.
I am so confused!