這裏的點擊添加一個div的內容到另一個DIV是我的代碼 -雖然上的按鈕
<div id="div1">
this is div 1
<form class="thisformtobeaddeverytime">
<!-- this form to be add on click #btn1 -->
</form>
</div>
<div id="div2">
this is div 2
<form class="thisformtobeaddeverytime">
<!-- this form to be add on click #btn2 -->
</form>
</div>
<div id="showtheaddedform">
//here my form will be push on click to button
</div>
<button type="button" id="btn1">Add the form1</button>
<button type="button" id="btn2">Add the form2</button>
// the click function in my js file are as -
$(document).on("click","#btn1",function(){
$("#showtheaddedform").append($("#div1").html());
});
$(document).on("click","#btn2",function(){
$("#showtheaddedform").append($("#div2").html());
});
現在的問題是 -
在點擊#bun1它添加的內容#DIV1到#showtheaddedform(即形式屬性和內部形式的所有元素),像
<div id="showtheaddedform">
<form class="thisformtobeaddeverytime">
<!-- this form to be add on click #btn1 -->
</form>
</div>
但是當我點擊#BTN2它的加入只有表單內的元素,像
<div id="showtheaddedform">
<!-- this form to be add on click #btn2 -->
</div>
[注:我沒有寫任何刪除查詢]
..any的想法,它是如何消除!
你的點擊事件沒有正確關閉 – Pavlo
點是only..all其他文本輸入可用它刪除表單標籤。 – Chinmoy
你是什麼意思***它去掉表單標籤只***你想移動'div'元素呢? – Pavlo