Constructors

Methods

  • Finds the root document from a given root node.

    Parameters

    • rootNode: Document | Element

      The root node (Document or Element).

    Returns Document | Element

  • Gets the index of an element among its siblings. Returns a 1-based index as used in CSS :nth-child pseudo-class.

    Parameters

    • element: Element

      The element to get the index for.

    Returns null | number

  • Gets the level (depth) of an element in the DOM tree relative to the root.

    Parameters

    • element: Element

      The element to get the level for.

    • root: Document | Element

      The root element.

    Returns number

  • Gets the position of the element among its siblings of the same type. Returns a 1-based index.

    Parameters

    • element: Element

      The element to get the index for.

    Returns null | number

  • Checks if an element matches a given CSS selector.

    Parameters

    • element: Element

      The element to test.

    • selector: string

      The CSS selector string.

    • context: Document | Element

      The context in which to perform the query (Document or Element).

    Returns boolean