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

197
Visualizações
How to toggle Bootstrap buttons one at a time

Hi I have this piece of code that allows me to toggle one at a time. However there is a bug where if I click the first button out of the two it does what I want but, when the second button is clicked I can't untoggle the first button. However if I select the second button first and then select the first button the second button gets untoggled and the first one is now active.

<button type="button" id="b1"class="btn btn-primary " data-bs-toggle="button" value="Toronto" onClick="GetWeatherInfo()">Toronto Oakvile

  var btn1 = document.getElementById('b1');
  var btn2 = document.getElementById('b2');
  var selectedCity;

  if (btn1.classList.contains('active')){
    btn2.classList.remove("active");
    var selectedCity=document.getElementById("b1").value;
  }
  else if(btn2.classList.contains('active')){
    btn1.classList.remove("active");
    var selectedCity=document.getElementById("b2").value;
  }
about 4 years ago · Santiago Gelvez
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