JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="test" value="Enabled"/>
<button id="enable">Enable</button>
<button id="disable">Disable</button>
JavaScript
// Plugin Code
jQuery.fn.enable = function(){
return this
.removeAttr( "disabled" )
.trigger( "disabled" );
};
jQuery.fn.disable = function(){
return this
.attr( "disabled", "disabled" )
.trigger( "disabled" );
};
jQuery.fn.disabled = function(){
return !!this.attr( "disabled" );
};
// Example
$("#enable").click(function(){
$("#test").enable();
});
$("#disable").click(function(){
$("#test").disable();
});
$("#test").bind( "disabled", function() {
$(this).val( $(this).disabled() ? "Disabled" : "Enabled" );
});