Uh, that's not what I'm asking at all. In the documentation example you're passing .add() the "p" selector which is a string. I want the end result to be the same except instead of passing a selector string like "p" I want to pass an existing jquery object. It doesn't seem to work this way and the only time more elements get added to to jquery object is if you use a selector.
Sso I want to do more like : $("div").css("border", "2px solid red") .add($(this).children()) //see how this line is different .css("background", "yellow"); On Dec 23, 12:50 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > As per the docs (http://docs.jquery.com/Traversing/add), > > $("div").css("border", "2px solid red") > .add("p") > .css("background", "yellow"); > > That will add a 2px red border around any 'div' element. > > Then add in a new selector and grab all of the <p> elements. Add a yellow > background to the previously selected <div> elements, as well as the newly > selected <p> elements. > > Does that clarify add()? > > I'm not sure I understand what it is you're trying to accomplish. Can you > explain what you need to do? > > > > On Wed, Dec 23, 2009 at 10:45 AM, Scott <polyp...@gmail.com> wrote: > > Maybe I'm not understanding the point of .add() but it doesn't really > > do what I'd expect nor can I figure out how to do what I thought would > > be simple. > > > I want to combine 2 jquery objects. > > > var $obj1 = $(".stuff"); > > var $obj2 = $(".morestuff"); > > $obj1.add($obj2); > > alert($obj1.length); > > > This doesn't do anything, it looks like .add() only accepts selection > > strings which in my example would work but in what I really need to do > > I have no selection string which would find the specific jquery > > objects. > > -- > Charlie Grieferhttp://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success.