/ Published in: jQuery
## PWToggleAttr
This jQuery Plugin allows you to toggle an attribute on/off on an element. e.g. the disabled element of an input. Examples and such are available on http://www.pixaweb.co.uk/resources
This jQuery Plugin allows you to toggle an attribute on/off on an element. e.g. the disabled element of an input. Examples and such are available on http://www.pixaweb.co.uk/resources
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* * @package pwToggleAttr * @description toggles an attribute of an element on click * @author Jared Clarke <[email protected]> * @copyright 2010 (c) Jared Clarke @ pixaweb.co.uk * @version 0.1 */ (function ($) { $.fn.pwToggleAttr = function (options) { var opts = $.extend({}, $.fn.pwToggleAttr.defaults, options); return this.each(function () { var _this = $(this), _target = (opts.target == false) ? _this : $(opts.target); _this.click( function (event) { event.preventDefault(); _target.attr(opts.attr, !_target.attr(opts.attr)); }); return _this; }); }; $.fn.pwToggleAttr.defaults = { target : false, attr : "disabled" }; })(jQuery);
URL: http://www.pixaweb.co.uk/resources?tag=jquery