View Full Version : how to use cloneNode
10-03-2002, 04:49 PM
i have a div, "abomb" that i want to clone. there is nothing on the page besides this div, and i don't want any depth in the hierarchy. i want the clone to just be a sibling of 'abomb'. how do i do it?
10-03-2002, 08:21 PM
i figured it out.
10-05-2002, 04:31 AM
:) If abomb has any children (stuff inside the element, such as text or other elements), you want to use cloneNode(true).
10-05-2002, 06:34 AM
I may be wrong here, but I believe
will not create the sibling relationship you wanted. I think
would do it.
:rolleyes: .... so I guess
would make them cousins :D
10-05-2002, 12:39 PM
yea that looks right. but if 'abomb' is the only thing on the page, then 'body' is after all its parentNode, so i guess document.body.appendChild(el) and the above one are pretty much the same thing ... or aren't they?
by the way, i couldn't get any cousins because 'abomb' doesn't have any previous siblings...:) if it did, though, i don't think appending a child to the previous sibling would keep the hierarchy flat, it would make 'abomb' el's uncle (or aunt ... :D)
10-06-2002, 04:33 AM
I didn't see the bit about only have that node on the page - in that case, yes, it amounts to the same thing.
And you're right - it would be cousin/uncle.
10-06-2002, 11:15 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.