I'm trying to write a code that when you click the button it shows and when pressed again it hides images. I made that images display to none and I want it to change to block when pressed the button (so it shows the images).
It works, but only when you click twice. What should I do to activate it on one click?
HTML :
<button id="categoryBtn" onclick="insta()">instagram users</button>
javascript :
function insta() {
var a = document.getElementById("instaBalas");
if (a.style.display == "none") {
a.style.display = "block";
}
else {
a.style.display = "none";
}
}
Aucun commentaire:
Enregistrer un commentaire