Skip to content

Instantly share code, notes, and snippets.

@uxmoon
Last active April 26, 2018 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uxmoon/ae2f3e2eadf544b1214ba5a555da1f1f to your computer and use it in GitHub Desktop.
Save uxmoon/ae2f3e2eadf544b1214ba5a555da1f1f to your computer and use it in GitHub Desktop.
vanilla js add multiple attributes
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