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

183
Visualizações
How to disable specific bootstrap button on click?

I have a table with buttons. My goal is whenever I click a button, it will disable. My problem is when I click the button, it only disable the first button in the column. What I want is to disable only the specific button that I have click. I used bootstrap for the table and buttons.

Here is my button:

<td>
    <input type="button" onclick="checker()" href="php/doneProblem.php?problemID=<?= $rows['problemID'] ?>" id="btn-done" class="btn btn-primary" value="Mark as Done" />
</td>

Here's how I disable the button:

 <script>
    function checker() {
        var result = confirm('Are you sure to mark this as done?');
        if (result == false) {
            event.preventDefault();
        } else {
            $('#btn-done').attr('disabled', true);
            $('#btn-done').addClass('disabled');
        }
    }
</script>

I tried using class instead of id but it disable all the buttons when I click a single button.

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

0

Instead of trying to target the item by ID you will want to target the item via event.target. This gives you reference to the specific button that was clicked. You can read more about event.target here.

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