Disable and enable buttons (Bootstrap) using a jQuery extension

A nice easy way to disable and re-enable buttons [etc] in Bootstrap with a little extension to the jQuery library.

Add this into the js file, either a custom.js or the main jQuery class file.  Custom being better so it doesn’t get overwriten in the future.

    disable: function (state) {
        return this.each(function () {
            var $this = $(this);
            $this.toggleClass('disabled', state);

Then use like this:





Share this post:
Related Posts
Send data to a Bootstrap modal
Getting the value or text of an HTML attribute using jQuery

Leave a Comment