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

132
Visualizações
Hide clicked button after toggle

I'm using this code to toggle the visibility of a section. When the button is clicked, the section shows.

function myFunction() {
  var x = document.getElementById("offerte-toggle");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}
<a onclick="myFunction()" id="knop-doorz" class="witte-randen">Offerte opvragen</a>

How can I hide the button after it has been clicked?

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

0

your JS code is targetting an element with id offerte-toggle but in your html, the has an id of knop-doorz

Either edit the html id to match the JS or vice versa.

You also don't need to do the if check, just simply set x.style.display = 'none'; before the closing } tag.

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