Skip to content

Instantly share code, notes, and snippets.

@padolsey
Created October 5, 2009 08:25
Show Gist options
  • Save padolsey/201983 to your computer and use it in GitHub Desktop.
Save padolsey/201983 to your computer and use it in GitHub Desktop.
/* Make getters return full set if first arg === true */
$.each(
[
'html', 'val', 'text', 'width', 'height', 'scrollTop',
'scrollLeft', 'hasClass', 'css', 'attr', 'offset',
'position', 'outerHeight', 'outerWidth'
],
function(){
var _method = $.fn[this];
if (!_method) {
return true;
}
$.fn[this] = function() {
var args = Array.prototype.slice.call(arguments);
if (args.shift() === true) {
return this.map(function(){
return _method.apply($(this), args);
});
}
return _method.apply(this, arguments);
};
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment