Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!