Is there a way for a pop-up to appear when all divs got ‘onmouseovered’?
function moveOver(obj) { obj.innerHTML = "POP!!!" obj.style.color = "#ff0000" obj.style.background = "transparent" if () { alert("There is no circles left!") } }
I basically have 12 circles that pop when you move your mouse over them, is there a way to make a pop-up that says “There is no circles left!” after I hover over the 12th circle?
Advertisement
Answer
Add a class to the element
obj.classList.add("popped");
and check the length
if (document.querySelectorAll(".popped").length === 12) {