Element, EventTarget, or CSS selector.
Property (e.g. someProperty) or attribute name (e.g. data-some-property) for the dataset entry.
Optionalvalue: DatasetValueOptional dataset value to check for.
elements!InvalidElementError if the specified target wasn't found.
HTML
<div
id="example"
data-is-active="false"
data-count="30"
data-label="Example"
>
...
</div>
Code
const element = findElement("#example")!;
hasDatasetEntry(element, "data-is-active");
// true
hasDatasetEntry(element, "isActive", "false");
// false ("false" cannot be a string, must be the boolean value `false`)
hasDatasetEntry(element, "data-count", 30);
// true
Returns true if the
targethas a dataset entry withkeyand optionally, the matchingvalue.