如何在下一个div之后移动div.例如,我有三个不同的div坐在这里.
<div class="div1">Div1</div>
<div class="div2">Div2</div>
<div class="div3">Div3</div>
Run Code Online (Sandbox Code Playgroud)
我想在第二个div之后移动第一个div.这意味着div2将是第一个,div1将是第二个.我有一堆相同的html格式.
我想执行类似的jquery
$(".div1").each(function() {
$(this).appendTo().$(this).after();
});
Run Code Online (Sandbox Code Playgroud)
如果这没有意义,请告诉我.
Jos*_*eph 23
要么
$(".div1").each(function() {
var item = $(this);
//either this:
item.next().after(item);
//or this:
item.insertAfter(item.next());
});
Run Code Online (Sandbox Code Playgroud)
anu*_*_io 10
以下是如何使用jQuery方式使用DOM剪切粘贴操作.
Var temp= $(“div1”).detach(); //Performs the cut operation
temp.insertAfter(“div2”); //Does the paste
Run Code Online (Sandbox Code Playgroud)