Last active
April 26, 2018 13:36
-
-
Save uxmoon/ae2f3e2eadf544b1214ba5a555da1f1f to your computer and use it in GitHub Desktop.
vanilla js add multiple attributes
This file contains 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
var el = document.querySelector('.button'); | |
function setAttributes(el, attrs) { | |
Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key])); | |
} | |
setAttributes(el, { | |
class: 'button button--lg button--inverted', | |
'data-src': 'https://player.vimeo.com/video/28629415?autoplay=false', | |
'data-padding-bottom': '56.25%', | |
href: 'javascript:void(0);' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment