[jQuery] Merging two jQuery collections
Hello,<div>
</div><div>I have two jQuery collections that I'd like to merge into one:</div><div>
</div><div>var foo = $('#foo');</div><div>var foobars = foo.nextAll('.bar');<br clear="all">
</div>
<div>I've tried using $.add() to combine the two, but it doesn't seem to be working:</div><div>
</div><div>foo.add(foobars);</div><div>foo.css('border', '2px solid #f00'); // only #foo is affected</div>
<div>
</div><div>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?</div><div>
</div><div>I cannot make changes to the HTML, so wrapping them in a container div is not an option.</div>
<div>
</div><div>Thanks in advance for the help!</div><div>
--
Hector
</div>