Sometimes you need to work with the top-level root element. To query it, you can use $.root().
$.root()
Cheerio instance wrapping the root node.
$.root().append('<ul id="vegetables"></ul>').html();//=> <ul id="fruits">...</ul><ul id="vegetables"></ul> Copy
$.root().append('<ul id="vegetables"></ul>').html();//=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
Cheerio.root
Sometimes you need to work with the top-level root element. To query it, you can use
$.root().