Function selectAll

  • Create an empty selection.

    Parameters

    • Optional selector: null

    Returns Selection<null, undefined, null, undefined>

  • Select all elements that match the specified selector string. The elements will be selected in document order (top-to-bottom). If no elements in the document match the selector, returns an empty selection.

    The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type.

    Type Parameters

    Parameters

    • selector: string

      CSS selector string

    Returns Selection<GElement, OldDatum, HTMLElement, any>

  • Select the specified array, array-like, or iterable of nodes. This is useful if you already have a reference to nodes, such as this.childNodes within an event listener or a global such as document.links. The nodes may instead be an iterable, or a pseudo-array such as a NodeList.

    The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the datum, of a selected element.

    Type Parameters

    Parameters

    • nodes: GElement[] | ArrayLike<GElement> | Iterable<GElement>

      An array, array-like, or iterable of nodes

    Returns Selection<GElement, OldDatum, null, undefined>