我想添加到表中,但我點擊添加按鈕2行添加simulataneously我的意思是循環運行兩次。但刪除行沒有問題。動態添加行到表中不工作使用jquery
$(document).ready(function() {
$(".add_partners_details").click(function() {
var newrow = $('<div class="t-row"><div class="t-col"><input type="text" class="text_field txtNumeric" name="partners_or_directors_sl_no_id[]" value="" placeholder=""/></div><div class="t-col"><input type="text" class="text_field txtNumeric" name="partners_or_directors_pin_id[]" value="" placeholder=""/></div><div class="t-col end"><input type="text" class="text_field required txtAlphabet" name="partners_or_directors_name_id[]" value="" placeholder=""/></div><div class="t-col border_none"><a href="javascript:void(0);" class="remove_partners_details">Remove</a></div></div>');
$("#details_of_partners_directors").append(newrow);
});
$("#details_of_partners_directors").on('click','.remove_partners_details',function() {
$(this).parent().parent().remove();
});
});
HTML
<div class="t-row">
<div class="t-col">
<input type="text" class="text_field txtNumeric"name="partners_or_directors_sl_no_id[]" value="" placeholder=""/>
</div>
<div class="t-col">
<input type="text" class="text_field txtNumeric" name="partners_or_directors_pin_id[]" value="" placeholder=""/>
</div>
<div class="t-col end">
<input type="text" class="text_field required txtAlphabet" name="partners_or_directors_name_id[]" value="" placeholder=""/>
</div>
<div class="t-col border_none">
<a href="javascript:void(0);" class="add_partners_details">Add</a>
</div>
</div>
沒有與id的元素'這個小提琴details_of_partners_directors' –
可能的複製... HTTP://jsfiddle.net/samliew/3AJcj/2/如果不張貼的我們的代碼小提琴.. – codebreaker
請參閱http:/ /jsfiddle.net/arunpjohny/9ta6D/1/ –