一个带有类的 div 框分别包含带有 ID和.my-row
的添加和删除按钮。Jquery 用于在单击按钮时克隆 div 框并使用按钮删除 div 框。我想要在添加和删除 div 框时淡入和淡出动画。#add-row
#remove-row
#add-row
#remove-row
HTML:
<div id="my-field">
<div class="grey-field">
//box i want to clone
<div class="my-row">
<a id ="add-row" class="button"></a>
<a id ="remove-row" class="button"></a>
</div>
</div>
</div>
jQuery
$('#add-row').on('click', function() {
var row = $('.my-row').clone(true);
row.removeClass('my-row');
row.insertBefore('#my-field .grey-field>div:last');
return false;
});
$('#remove-row').on('click', function() {
$(this).closest("div").fadeOut(600, function(){
$(this).remove();
});
return false;
});