I'm working with some jquery and found a weird behaviour of jquery .appendTo()
function.
Look this code here.
When you click on each item of the first column, the clicked item is appended to the second column.
If you click items 3
and 4
, everything will work as expected: They will be appended in the order you clicked them.
When you click on item 1
, he will be appended correctly too.
The problem is when you click on item 2
. This item is inside the item 1
.
This item is not appended to the end of the div, he' is appended on top of his old parent!
Look the images:
Now, what I was expecting versus what I get:
If you click again on item 2
he will be appended at the end of the div.
This behaviour have some explanation? It's a bug in fact?
How can I workaround this?
Ps: Jquery 1.10.1