• Removes the dataset entry with attribute/property name key from the target.

    Type Parameters

    Parameters

    • target: null | Target

      Element, EventTarget, or CSS selector.

    • key: string

      Dataset property or attribute name for the dataset entry to remove.

    Returns E

    Element representation of the specified target.

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

    HTML (Before)

    <div
    id="example"
    data-is-active="false"
    data-count="30"
    data-label="Example"
    >
    ...
    </div>

    Using Attribute Name (data-*)

    const element = findElement("#example")!;

    removeDatasetEntry(element, "data-label");

    Using Property Name (camelCase)

    const element = findElement("#example")!;

    removeDatasetEntry(element, "label");

    HTML (After)

    <div
    id="example"
    data-is-active="false"
    data-count="30"
    >
    ...
    </div>