Skip to content

Instantly share code, notes, and snippets.

@UcheSylvester
Last active June 30, 2019 08:07
Show Gist options
  • Save UcheSylvester/a4c0daa3523711d23370ed1f55dcd855 to your computer and use it in GitHub Desktop.
Save UcheSylvester/a4c0daa3523711d23370ed1f55dcd855 to your computer and use it in GitHub Desktop.
setAttributes.js
// setAttributes function for setting multiple attributes to a particular element at once!
function setAttributes(element, attributes) {
for(let key in attributes) {
element.setAttribute(key, attributes[key])
}
}
// Call it like this:
setAttributes(element, {"class": "center", "width": "100%", "height": "100%", ...});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment