我想克隆div的內容使用jQuery,但從複製的內容我想從原來的一個類刪除我使用appendTo函數之前。當我從克隆中刪除課程時,他們也從原始課程中刪除課程。克隆div和刪除類沒有改變原來的
我的代碼是:
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
next.children(':first-child').addClass('col-sm-offset-1');
for (var i=0;i<3;i++) {
next=next.next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
請注意,我不想從實際DIV從那裏我複製了內容刪除類,我只是想從複製的代碼中刪除,以便它是不包括在克隆的div中。
我沒有看到代碼刪除類,您可以更新刪除類,你在哪裏試圖刪除類 – LazyDeveloper
next.children代碼(「:第一個孩子」)。removeClass(「同事SM-偏移-1' )克隆)。()appendTo($(本); //這裏我刪除克隆div類 – suraj