queryElements()function

queryElements(elements: Elements, query: Query<Element>): Iterable<Element>
ParamType
elementsElements
The elements to walk and filter. required
queryQuery<Element>
The Query<Element> object describing the filter, sort, and limit to apply. required
Return
Iterable<Element>
An iterable of the matching Element objects.

Filter elements yielded by walkElements() using a Query<Element> object.

  • Supports any property query (e.g. { type: "tree-element" }, { type: ["tree-element", "tree-documentation"] }), sorting, limiting — anything queryItems() accepts.

Examples

[...queryElements(elements, { type: "br" })] // all `<br>` elements