I want to clone the contents of a div using jQuery, but from the copied content I want to remove the class from the source before using the appendTo function. When I delete a class from a clone, they are also deleted from the original.
My code is:
$('.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)); } });
Please note: I do not want to remove the class from the actual div where I copied the content, I just want to remove it from the copied code so that it is not included in the cloned div.
suraj source share