Element representation of target
.
Element, EventTarget, or CSS selector.
Object with key of attribute name and value of attribute value.
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>
Sets the attributes of the
target
to theattributes
object, where the key of the object is the attribute name and the value of the object is the attribute value.