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

193
Visualizações
Enable and disable. One then the other

One button shows the user local time when clicked. Then I have another button that stops the clock. I am trying to disable "show local time" when the button "stop time" is clicked.

<button id="start" onclick="showTime()" >Show Local showTime</button> <button id="stop" onclick="myStop()">Stop Time</button>

This is my code in HTML

I've tried this for my javascript document.getElementById(start).disabled = true; document.getElementById(stop).removeAttribute('disabled')

Tried this

function showTime() {
    document.getElementById("start").disabled = true;
  }
  
  function myStop() {
    document.getElementById("stop").disabled = false;
  }

None of these have works for disabling the other button. They both are being allowed to be clicked.

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

0

As far as I got the question, you need to disable one button when you click the other button. I will post an answer that will do the work.

function showTime() {
    document.getElementById("stop").disabled = !document.getElementById("stop").disabled;
}
  
function myStop() {
    document.getElementById("start").disabled = !document.getElementById("start").disabled;

}

When you click the show local time button,

  • it will disable the stop time if stop time is enabled
  • it will enable the stop time if stop time is disabled

When you click the stop time button,

  • it will disable the show local time if show local time is enabled
  • it will enable the show local time if show local time is disabled
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