set-attribute-tuples
v1.0.1
Published
Apply multiple attribute values to an HTMLElement.
Downloads
2
Readme
setAttributeTuples
Sets multiple attributes to an Element.
Installation
npm install set-attribute-tuples
import setAttributeTuples from "set-attribute-tuples"
Usage
Set multiple attributes
const div = document.createElement("div");
setAttributeTuples(div, [ ["id", "undo"], ["class", "btn-wrapper"] ]);
console.log(div.className);
//"btn-wrapper"
(Typescript) Optionally cast as a specific element type
const div = document.createElement("div");
const div = setAttributeTuples<HTMLDivElement>( div, [["data-blah", "12345"]]
);
console.log(div.dataset.blah)
// "12345"
Development
| description | npm | yarn |
|:--------------:|:---------------------:|:------------:|
| Build package | npm run build
| yarn build
|
| Run tests | npm run test
| yarn test
|