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

267
Visualizações
What is the logic of html and js?

I have a small test. When I click on the "click" button, the display is good which changes the color, but console.log shows that the code is not working according to the logic I put in.

In the beginning, the color is black, that's correct I clicked the button the color turn to red, that's correct but looking at the console, I think "show bar" must be shown first.

I may do something wrong, or my logic was wrong. Please help me.

function hideShow() {
  const footer = document.getElementById("footer");
  authorInfo = document.getElementById("authorInfo");
  if (footer.style.display === "none") {
    footer.style.display = "block";
    authorInfo.style.display = "none";
    console.log("show bar");
  } else {
    footer.style.display = "none";
    authorInfo.style.display = "flex";
    console.log("hide bar");
  }
}
<div id="footer" class="item" style="
        width: 100px;
        height: 200px;
        background-color: black;
        display: flex;
      "></div>
<div id="authorInfo" class="object" style="width: 100px; height: 200px; background-color: red; display: none"></div>
<button type="button" onclick="hideShow()">click</button>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're checking if (footer.style.display === "none") which is false accordingly to the HTML you provided as it contains the display: flex; property. Therefore, the else block of your conditional is executed.

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