Ciao a tutti,
con js ho impostato che il valore top di un immagine varia nel tempo
ora vorrei fermare tale funzione quanto top raggiunge il valore -200% ma così non funzionacodice:var img = document.getElementById("imgEs"); var counter = 0; myVar = setInterval(function(){ counter += -0.07; img.style.top = img.innerHTML += counter.toString() + '%'; }, 1);
Come potrei risolvere?codice:setInterval(function(){ if (img.style.top < -50 + '%') { clearInterval(myVar); } }, 1);
Grazie