Last active
June 30, 2019 08:07
-
-
Save UcheSylvester/a4c0daa3523711d23370ed1f55dcd855 to your computer and use it in GitHub Desktop.
setAttributes.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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