Skip to content

Instantly share code, notes, and snippets.

@danhollick
Created February 4, 2020 10:42
Show Gist options
  • Save danhollick/9b74a33bd0f755a3f38bb6513fe247c0 to your computer and use it in GitHub Desktop.
Save danhollick/9b74a33bd0f755a3f38bb6513fe247c0 to your computer and use it in GitHub Desktop.
color change function
function changeColor(classname, color) {
const elements = document.getElementsByClassName(classname)
for (let i = 0; i < elements.length; i++) {
if (elements[i].localName === 'div') {
elements[i].style = `background-color: ${color};`
} else {
elements[i].style = `color: ${color};`
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment