.add() isn't destructive - calling it does not modify the original
object (so, it's unlike an array's .push(), for example). Therefore to
get your second example working you'd have to do:

var test = $('form');
test = test.add ('li');
console.log (test);

--John

On 6/20/07, Gordon <[EMAIL PROTECTED]> wrote:

I wanted to create an empty jQuery object and add elements to it for
later use but I couldn't get it to work.  Eventually I started
experimenting and discovered the following:

var test = $('form').add ('li');
console.log (test);

will return a jQuery object containing a list of forms plus a list of
li elements.


var test = $('form');
test.add ('li');
console.log (test);

will return a jQuery object as well but this time it only contains the
form elements.

Is this what's supposed to happen or is it a bug?  It happened with
both 1.1.2 and 1.1.3a as the jQuery library.


Reply via email to