setattributes

1.0.0 • Public • Published

setAttributes

Set and delete multiple attributes in a DOM element.

This...

const el = document.querySelector("input");

el.setAttribute("type", "password");
el.setAttribute("name", "password-field");
el.removeAttribute("maxlength");

...is equivalent to this:

const setAttributes = require("setattributes");

const el = document.querySelector("input");

setAttributes(el, {
  type: "password",
  name: "password-field",
  maxlength: null,
});

Package Sidebar

Install

npm i setattributes

Weekly Downloads

0

Version

1.0.0

License

Unlicense

Unpacked Size

3.11 kB

Total Files

5

Last publish

Collaborators

  • evanhahn