Oh, that makes sense. Thanks! -- Hector
On Fri, Aug 14, 2009 at 2:13 PM, Ricardo <ricardob...@gmail.com> wrote: > > .add() returns the merged collections, but it doesn't change 'foo'. > you have to reassign it: > > foo = foo.add(foobars); > > On Aug 14, 2:36 pm, Hector Virgen <djvir...@gmail.com> wrote: > > Hello, > > I have two jQuery collections that I'd like to merge into one: > > > > var foo = $('#foo'); > > var foobars = foo.nextAll('.bar'); > > > > I've tried using $.add() to combine the two, but it doesn't seem to be > > working: > > > > foo.add(foobars); > > foo.css('border', '2px solid #f00'); // only #foo is affected > > > > I've confirmed that foo and foobars both contain elements by checking the > > length property. Is there a way to merge two or more collections into > one? > > > > I cannot make changes to the HTML, so wrapping them in a container div is > > not an option. > > > > Thanks in advance for the help! > > > > -- > > Hector >