Trilium Backend API
    Preparing search index...
    • The .unwrap() function, removes the parents of the set of matched elements from the DOM, leaving the matched elements in their place.

      Type Parameters

      Parameters

      • this: Cheerio<T>
      • Optionalselector: string

        A selector to check the parent element against. If an element's parent does not match the selector, the element won't be unwrapped.

      Returns Cheerio<T>

      The instance itself, for chaining.

      const $ = cheerio.load(
      '<div id=test>\n <div><p>Hello</p></div>\n <div><p>World</p></div>\n</div>',
      );
      $('#test p').unwrap();

      //=> <div id=test>
      // <p>Hello</p>
      // <p>World</p>
      // </div>
      const $ = cheerio.load(
      '<div id=test>\n <p>Hello</p>\n <b><p>World</p></b>\n</div>',
      );
      $('#test p').unwrap('b');

      //=> <div id=test>
      // <p>Hello</p>
      // <p>World</p>
      // </div>