[英].before to insert multiple elements
I have an element var destination
which I'm trying to insert multiple elements before it. 我有一个元素
var destination
,我试图在它之前插入多个元素。 I use .before
but I use it multiple times because I'm moving multiple elements. 我使用
.before
但是我多次使用它,因为我要移动多个元素。
Is there a way to improve this code, and move all the elements at once? 有没有一种方法可以改进此代码,并一次移动所有元素? I'm moving an element
moveElement
, the element before it, and a number of other elements that have the class myClass
using each()
. 我正在移动元素
moveElement
,它之前的元素以及其他一些使用each()
类myClass
的其他元素。 Any way to reduce the number of destination.before()
任何减少
destination.before()
数量的方法。
destination.before(moveElement.prev());
destination.before(moveElement);
$('div.myClass').each(function(){
destination.before($(this));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.