解決
var $tcMain = $(this).children().not('.tc-remove').clone()
問題
HTML 要素から jQuery オブジェクトを引き出しており.tc-remove
、さらに挿入するために、クラスを含むすべての要素を削除したいと考えています。
現在のコード:
HTML
<div class='tc'>
<p> To be kept </p>
<div class='tc-remove'> To be removed </div>
<span> To also be kept </span>
</div>
jQuery
$('.tc').each(function(i,v){
// Clone and strip redundant elements
var $tcMain = $( $(this).clone().not('.tc-remove') )
$create = $('<div>').append($tcMain.html())
})
.html() が不要であることをお勧めします!