Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda