mercredi 24 décembre 2014

something wrong with my loop?


I want to make a box disappear and reappear alternatively by using the loop. The problem is that the box does not appear at all though the loop runs until i=10. Can someone explain this?



for(var i=0;i<10;i++){
if(document.getElementById("box").style.display=="none"){
document.getElementById("box").style.display="block";}
else{
document.getElementById("box").style.display="none";
}
console.log(i);
}




Aucun commentaire:

Enregistrer un commentaire