2016-12-02 19 views
2

$(this).parent()を別のdivに追加してから$this要素を削除します。
$this要素を正常に削除できました。しかし、.append($(this).parent())は間違ったアプローチで動作していないようです。 $this要素を削除する前に別のdivに正確なコピーを作成したい要素を複製して、クローン化された要素を追加するために使用clone() https://jsfiddle.net/rvgo3Luc/HTML要素にJqueryオブジェクトを追加します

+2

'.append($(この).parent()。クローン())' ?? – epascarello

+0

@epascarelloありがとう。 –

答えて

0

は、問題文を再現しました。

$("#button").on("click", function(){ 
    console.log($(this).parent()); 
    // I have to copy this element into say a new div and remove this present element. 
    // How to append $(this).parent() 
    $("#a").append($(this).parent().clone()); 
    $(this).remove(); 
}) 

JSFIDDLE

関連する問題