Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
How do I reset an image, after being removed, using if assignment, in javascript

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.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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);
about 4 years ago · Juan Pablo Isaza Report

0

Man You put a single equal there ! do == or === then this thing will definetly work by resetElement("Mono"); and resetElement("Tri);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!