@laserware/dominator
    Preparing search index...

    Function setAttribute

    • Sets the attribute name of the target element to the value. The value is coerced to a string.

      Type Parameters

      Parameters

      • target: null | Target

        Element, EventTarget, or CSS selector.

      • name: AttributeName<E>

        Name of the attribute to set.

      • value: undefined | null | AttributeValue

        Value to set for the attribute.

      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("#example")!;

      element = setAttribute(element, "aria-label", "Click me");

      HTML (After)

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