如何動態添加/刪除文本框(不清除文本框的數據)和相應的刪除按鈕上相應的刪除按鈕點擊事件通過javascript?Javascript添加/刪除文本框和相應的刪除按鈕
注意:每個動態創建的文本框都有單獨的按鈕。
以下是我的javascript功能。我使用jQuery 1.3.2
function addOption()
{
var d=document.getElementById("yash");
d.innerHTML+="<input type='text' id='mytextbox' name='textbox' class='form-field medium' >";
d.innerHTML+="<input type='button' id='mybutton' name='del'>";
$("#mybutton").click(function() {
$("#mytextbox").remove();
$(this).remove();
});
d.innerHTML+="<br/>";
}
什麼ü由不清除文本框的數據是什麼意思?如果你刪除它肯定會去。你想刪除它還是隻隱藏它。 –
我的意思是我不想清除文本框。我想刪除文本框也是相應的刪除按鈕,我點擊它刪除其核心指示文本框。 – Yash