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 <[email protected]> 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 Griefer
http://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.