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

260
Visualizações
Different buttons toggling same content

there are 3 buttons and when you click 3 of them showing the same content. I need to show unique content of buttons when you click on them seperately. how to make each button should show div's unique content?

function myFunction() {
  var x = document.getElementById("myDIV");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
span {
cursor:pointer;}
<span onclick="myFunction()"class="total">button</span>
<div id="myDIV" style="display:none;" class="expandable">
   content 1
</div>
<span onclick="myFunction()" class="total">button2</span>
<div id="myDIV" style="display:none;" class="expandable">
   content 2
</div>
<span onclick="myFunction()" class="total">button3</span>
<div id="myDIV" style="display:none;" class="expandable">
   content 3
</div>

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

0

You gave the 3 divs the same ID , Which is not what you want ofcourse because the id is a unique selector for items .

From this point you can solve your problem

Regards

about 4 years ago · Juan Pablo Isaza Relatório

0

why you have same id for three buttons? I think you can update its content by different button id.

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