Created
October 22, 2012 03:18
-
-
Save sjwilliams/3929462 to your computer and use it in GitHub Desktop.
Merge an array of jQuery objects into a single usable selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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