Skip to content

EvanHahn/setAttributes

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

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

Installation

npm install setattributes

Then, to import it:

import setAttributes from "setattributes";

About

call .setAttribute on a DOM node more easily

Resources

License

Stars

Watchers

Forks

Packages

No packages published