Friday, May 1, 2015

How to disable/enable buttons and links (jQuery + Bootstrap)

jQuery.fn.extend({
   disable: function (state) {
      return this.each(function () {
         var $this = jQuery(this);
         if ($this.is('input, button'))
            this.disabled = state;
         else if($this.is('a'))
            $this.toggleClass('disabled', state);
      });
   }
});

No comments:

Post a Comment