Skip to content

Instantly share code, notes, and snippets.

@wangwen1220
Last active December 14, 2016 08:35
Show Gist options
  • Save wangwen1220/8310304 to your computer and use it in GitHub Desktop.
Save wangwen1220/8310304 to your computer and use it in GitHub Desktop.
JS: jQuery 切换启用和禁用 | toggle disabled input
// jQuery 切换启用和禁用表单项
(function ($) {
$.fn.toggleDisabled = function() {
return this.each(function() {
var $this = $(this);
if ($this.attr('disabled')) $this.removeAttr('disabled');
else $this.attr('disabled', 'disabled');
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment