开发者

create a next cycle

I am trying to create an infinite cycle of elements using the following code:

$('div').click(function(){
   move = $(this).detach();
   $(this).parent(开发者_如何学编程).append(move);
});

but it just seems to be removing my objects, rather than moving them to the end of the list in order to create the cycle

Where are I going wrong?


move = $(this).detach();

That line removes the element from the DOM. Once you have done this it has no parent. Just remove this line all together.


$(this).parent().append(this);

should be sufficient. It will automatically remove the element and place it where it belongs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜