Skip to content

Instantly share code, notes, and snippets.

@sjwilliams
Created October 22, 2012 03:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sjwilliams/3929462 to your computer and use it in GitHub Desktop.
Save sjwilliams/3929462 to your computer and use it in GitHub Desktop.
Merge an array of jQuery objects into a single usable selector
// Based on pieces from this thread:
// http://stackoverflow.com/questions/1881716/merging-jquery-objects
// use: var currentRowEls = []; // array of various jQ ojbects
// $.mergeSelectors(currentRowEls).css({width:'200px'});
(function($){
$.mergeSelectors = function(objs) {
var ret = objs.shift();
while (objs.length) {
ret = ret.add(objs.shift());
}
return ret;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment