Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable bootstrap button after one click using javascript

How do I disable a Bootstrap button after it is clicked using Javascript. I am using the onclick event but it doesn't get disabled.

Code:

<div class="panel-heading">
    <div class="btn-group pull-right"> 
         <a href="/assign" class="btn btn-success">Assign</a>
         <a href="#" class="btn btn-primary" onclick="this.disabled=true">Upload</a>
   </div>
</div>
like image 409
Shashidhar Avatar asked Mar 12 '16 10:03

Shashidhar


2 Answers

$("#buttonid").on("click", function() {
    $(this).prop("disabled", true);
});
like image 128
chris97ong Avatar answered Sep 28 '22 17:09

chris97ong


add

$(this).prop("disabled",true);

to you click event function

like image 34
Jesper Christensen Avatar answered Sep 28 '22 18:09

Jesper Christensen