Trilium Backend API
    Preparing search index...
    • Iterates over a cheerio object, reducing the set of selector elements to those that match the selector or pass the function's test.

      This is the definition for using type guards; have a look below for other ways to invoke this method. The function is executed in the context of the selected element, so this refers to the current element.

      Type Parameters

      • T
      • S

      Parameters

      • this: Cheerio<T>
      • match: (this: T, index: number, value: T) => value is S

        Value to look for, following the rules above.

      Returns Cheerio<S>

      The filtered collection.

      $('li')
      .filter(function (i, el) {
      // this === el
      return $(this).attr('class') === 'orange';
      })
      .attr('class'); //=> orange
    • Iterates over a cheerio object, reducing the set of selector elements to those that match the selector or pass the function's test.

      • When a Cheerio selection is specified, return only the elements contained in that selection.
      • When an element is specified, return only that element (if it is contained in the original selection).
      • If using the function method, the function is executed in the context of the selected element, so this refers to the current element.

      Type Parameters

      • T
      • S

      Parameters

      Returns Cheerio<S extends string ? Element : T>

      The filtered collection.

      $('li').filter('.orange').attr('class');
      //=> orange
      $('li')
      .filter(function (i, el) {
      // this === el
      return $(this).attr('class') === 'orange';
      })
      .attr('class'); //=> orange