1.0.0 • Published 3 years ago

setattributes v1.0.0

Weekly downloads
3
License
Unlicense
Repository
github
Last release
3 years ago

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,
});