When appending element A to set B the element is moved over in the DOM
into the first element in B. All subsequent elements are cloned
(therefore it's not left in position).

Also, there's no need to do what you outlined, just do:
$("<div/>").append( $("#old_parent").children() );

--John



On Sat, Dec 12, 2009 at 12:11 PM, Raul DIas <rauld...@gmail.com> wrote:
> please, enlight me.
>
> $(A).appendTo(B) will move $(A) to selector B, which in most cases has
> to be an ID or a unique identified element.
>
> For this behaviour, what happens if B specifies multiple elements
> (e.g. class, element selector)?
>
>     WIll it clone and copy $(A) ?
>
>         If so, the original $(A) will still be in the same parent?
>
> appendTo() should accepts elements and jq objects too as it would be
> more clear (and avoid) the multi-element selector problem.
>
> Here is a behaviour that I would like to replicate in pure jQuery:
>
> 1 - Create an "anonymous" element:
>                var divContent = document.createElement("div");
>        or
>                 var divContent = $("<div/>");
>
> 2 - move (reparent) the children from '#old_parent' to the new element
> (divContent):
>
>    A - Using jQuery + DOM:
>                $("#old_parent").children().each(
>                        function() {
>                                divContent.appendChild(this);
>                        }
>                );
>
>    B - Using jQuery (or how it would have being) (wont work):
>                $("#old_parent").children().appendTo(divContent);
>
> Using a selector is not possible when dealing with anonymous elements.
>
> So, am I missing something?
>
> Can this be considered a bug?
>
> -rsd
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "jQuery Development" group.
> To post to this group, send email to jquery-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> jquery-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/jquery-dev?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to