如何在下一个div后移动div [英] How do I move div after its next div
本文介绍了如何在下一个div后移动div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在下一个div后移动div。
例如我有3个不同的div坐在这里。
< div class =div1> Div1< / DIV>
< div class =div2> Div2< / div>
< div class =div3> Div3< / div>
我想在第二个div后移动第一个div。这意味着 div2
将是第一个, div1
将是第二个。我有一堆相同的html格式。
我想执行jquery,像
<$ (); $ b $(this).appendTo()。$(this).after();
});
让我知道这是否合理。
.next() >元素,然后将其放置 .after()
或
您可以 .insertAfter() .next()元素
$(。div1)。each(function(){
var item = $(this);
(或):
item.next()。after(item);
//或this:
item.insertAfter(item.next());
});
How do I move a div after its next div. For instance I have 3 different div sitting here.
<div class="div1">Div1</div>
<div class="div2">Div2</div>
<div class="div3">Div3</div>
I wan to move first div after the second div. It means div2
will be first and div1
will be second. I have bunch of same html format.
I want to execute jquery something like
$(".div1").each(function() {
$(this).appendTo().$(this).after();
});
Let me know if this doesn't make sense.
解决方案
you can get the .next() element, and place it .after()
or
you can .insertAfter() the .next() element
$(".div1").each(function() {
var item = $(this);
//either this:
item.next().after(item);
//or this:
item.insertAfter(item.next());
});
这篇关于如何在下一个div后移动div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文