Skip to content

Instantly share code, notes, and snippets.

@FuruholmAnton
Created December 1, 2017 20:39
Show Gist options
  • Save FuruholmAnton/5ebf084b33a1be3796afed56fe9125f4 to your computer and use it in GitHub Desktop.
Save FuruholmAnton/5ebf084b33a1be3796afed56fe9125f4 to your computer and use it in GitHub Desktop.
/**
* Set CSS values on element
*
* @param {any} el
* @param {Object} styles
*/
function css(el, styles) {
if (!el) return;
if (Array.isArray(el) || el instanceof NodeList) {
el.forEach((n) => {
css(n, styles);
});
} else {
for (let [key, value] of entries(styles)) {
el.style[key] = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment