Function root

  • Sometimes you need to work with the top-level root element. To query it, you can use $.root().

    Example

    $.root().append('<ul id="vegetables"></ul>').html();
    //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>

    Returns

    Cheerio instance wrapping the root node.

    Alias

    Cheerio.root

    Parameters

    Returns Cheerio<Document>