Tag name of the Element representation of target
.
Element, EventTarget, or CSS selector.
Array of attribute names or attributes filter object to check for.
true
if the target
matches some search criteria.
elements!InvalidElementError
if the specified target
wasn't found.
HTML
<div id="example" aria-hidden="true" inert>Example</div>
Code
Note that the aria-label
attribute isn't present on the div
above,
but the function still returns true
:
const element = findElement("#example")!;
hasSomeAttributes(element, ["aria-hidden", "aria-label"]);
// true
hasSomeAttributes(element, {
inert: null,
"aria-hidden": true,
"aria-label": "Click Me",
});
// true
Checks if the
target
has some of the attributes that match thesearch
criteria.