function show(ev) { var element = (ev.target||ev.srcElement); element.style.backgroundColor = "white"; } function addAll(){ var item; var checks = document.getElementsByTagName("span"); for (item of checks){ if (item.getAttribute("class") == "check"){ item.addEventListener("click", show, false); } } } window.onload = addAll; bubbly({ colorStart: '#fff4e6', colorStop: '#ffe9e4', blur:1, compose: 'source-over', bubbleFunc:() => `hsla(${Math.random() * 50}, 100%, 50%, .3)` });