Skip to content

Instantly share code, notes, and snippets.

@benatkin
Created June 7, 2009 06:43
Show Gist options
  • Select an option

  • Save benatkin/125199 to your computer and use it in GitHub Desktop.

Select an option

Save benatkin/125199 to your computer and use it in GitHub Desktop.
(function($) {
$(document).ready(function() {
// adds support for setting multiple css attributes with one call to css()
// Example: $('.foo').css('background', 'black', 'color', 'white')
$.fn.css_orig = $.fn.css;
$.fn.css = function() {
var sel = this;
if (arguments.length > 2) {
for (var i = 0; i < arguments.length; i += 2) {
sel = sel.css_orig(arguments[i], arguments[i + 1]);
}
return sel;
} else {
return sel.css_orig.apply(sel, arguments);
}
};
// adds support for setting multiple DOM attributes with one call to attr()
// Example: $('#foo').attr('name', 'foo', 'class', 'foo')
$.fn.attr_orig = $.fn.attr;
$.fn.attr = function() {
var sel = this;
if (arguments.length > 2) {
for (var i = 0; i < arguments.length; i += 2) {
sel = sel.attr_orig(arguments[i], arguments[i + 1]);
}
return sel;
} else {
return sel.attr_orig.apply(sel, arguments);
}
};
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment