With this function I am able to remove these two images from the webpage
function removeElement(){
document.getElementById("imgbox1").style.display = "none";
document.getElementById("imgbox2").style.display = "none";
And with this function I am able to reset the images, after I click on a button
function resetElement(Ali){
document.getElementById("imgbox3").style.display = "block";
if (Ali = "Mono"){
document.getElementById("imgbox1").style.display = "block";
}
else if(Ali = "Tri"){
document.getElementById("imgbox2").style.display = "block";
}
}
With the code that I have I am able to reset the first image, however I which to be able to reset the second image using an if assignment. I am having trouble with the if's, because the code is only going through the first if.
CodePudding user response:
No matter what, only one of the two if-blocks in resetElement() will ever be executed in a single call to the function, because Ali will either equal "Mono" or "Tri" (or maybe neither) but never both.
The only way to execute both would be to call the function twice with different arguments, eg:
resetElement("Mono");
resetElement("Tri);
CodePudding user response:
Man You put a single equal there ! do ==
or ===
then this thing will definetly work by
resetElement("Mono");
and
resetElement("Tri);