« Return to Thread: Creating an empty jQuery object

Re: Creating an empty jQuery object

by malsup :: Rate this Message:

Reply to Author | View in Thread

> var result = [empty jQuery object];
> $.each(...
>   var element = ...;
>   result.add(element);
> );
>
> But how to create an empty jQuery? Scouring the source code, I eventually

You can just flip the logic around.  Instead of creating an empty
jQuery object and adding elements to it, build the array of elements
and then wrap it in a jQuery object:

var result = [];
$.each(...
        var element = ...;
        result.push(element);
);
var jq = $(result);

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

 « Return to Thread: Creating an empty jQuery object