我想将其添加到表中,但是当我单击添加按钮时,2 行正在同时添加,我的意思是循环运行两次。但是删除行没有问题。
$(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>