My website uses Bootstrap and a KendoUI data grid where each row has a button like this...
<button type="button" id="requestbtn1" class="btn btn-success">Request</button>
I've written some JavaScript to handle the click events of these buttons...
$("button[id^='requestbtn']").click(function() {
var lgid = String(this.id).replace("requestbtn", "");
alert("Request for slip " + lgid);
this.html("Done");
this.addClass("btn-primary");
this.removeClass("btn-success");
});
Although the alert shows the correct number, I'm having trouble changing the button text to "Done" and updating its CSS class to "btn-primary" to indicate that the request has been made.
Unfortunately, none of my attempts at changing the text and class have worked. Originally, I had all the changes in one line...
this.html("Done").addClass("btn-primary").removeClass("btn-success");
...but I tried splitting them up to troubleshoot the issue.
If anyone knows how I can successfully change the text and CSS class of the button, please let me know!