• Sets the attributes of the target to the attributes object, where the key of the object is the attribute name and the value of the object is the attribute value.

    Type Parameters

    Parameters

    • target: null | Target

      Element, EventTarget, or CSS selector.

    • attributes: Attributes<E>

      Object with key of attribute name and value of attribute value.

    Returns E

    Element representation of the specified target.

    elements!InvalidElementError if the specified target wasn't found.

    HTML (Before)

    <div id="example" role="slider">
    ...
    </div>

    Code

    let element = findElement<HTMLDivElement>("#example")!;

    element = setAttributes(element, {
    "aria-label", "Click me",
    "aria-valuenow": 20,
    });

    HTML (After)

    <div
    id="example"
    role="slider"
    aria-label="Click me"
    aria-valuenow="20"
    >
    ...
    </div>