JSFiddle - React, Tailwind, and code Playground

by Andrew

HTML

<button id="myButton" disabled="disabled">button</button>
<input type="checkbox" id="myCheck" />

JavaScript

(function($) {
    $.fn.toggleDisabled = function() {
        return this.each(function() {
            var $this = $(this);
            if ($this.attr('disabled')) $this.removeAttr('disabled');
            else $this.attr('disabled', 'disabled');
        });
    };
})(jQuery);

$(function() {
    $('#myCheck').click(function() {
        $('#myButton').toggleDisabled();
    });
});