Last active
August 29, 2015 14:09
-
-
Save duzun/01e5fbded0b62987d3f6 to your computer and use it in GitHub Desktop.
A small jQuery plugin to enable/disable any form element, and any generic element (with 'disabled' class)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A small jQuery plugin to enable/disable any form element, | |
* and any generic element (with 'disabled' class) | |
*/ | |
;(function (global) { | |
var $ = global.jQuery || global.Zepto; | |
$.fn.enable = function (cls) { | |
var prp = 'disabled'; | |
cls || (cls = prp); | |
this.attr(prp, null).prop(prp, false).removeClass(cls); | |
return this; | |
}; | |
$.fn.disable = function (cls) { | |
var prp = 'disabled'; | |
cls || (cls = prp); | |
this.attr(prp, prp).prop(prp, true).addClass(cls); | |
return this; | |
}; | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment