I am also a newby with jQ, so I won't be able to help you with the
'name' of the cloned element - I suspect it is the same as the
original.

Here is what I did to 'swap' divs - maybe it will help you (probably
superfluous for some people's liking - I am open for better code):

var clonedSource = $('#source1').clone(true); //clone the source
$('#source1').replaceWith($('#source2'));  //replace the source1 in
position with the 'swapped' source
$('#source2Container').append(clonedSource);  //append cloned source1
in the position of source2

That 'swapped' two elements for me.

> I'm just a noob with jQ, but I'd rather .remove AFTER
> the .append...no ?

In ak732's snippet the 'remove()' function returns the removed
element, so that is why you can append it.  You could also have
written it as:

var removedElement = $('#source').remove();
$('#target').append(removedElement);

Hope that helps

Reply via email to