So I have a simple javascript that looks like this
function myfunction(){
var a = [document.getElementById("div1"),
document.getElementById("div2"), document.getElementById("div3")];
if(a.style.display=="none"){
setTimeout(function(){a.style.display="block";},4000);
}
}
And html code looks like this
< a href="#" onclick="myfunction();" > click to show div1 and div2 after 4 seconds< /a >
< p id="div1" style="display:none;" >divv1< /p >
< p id="div2" style="display:none;" >divv2< /p >
< p id="div3" style="display:none;" >divv3< /p >
However divs are not showing after 4 seconds after I clicked.
Is there something wrong with my code?
Can someone please guide me further?
Thanks alot!
Aucun commentaire:
Enregistrer un commentaire