您需要使用事件委托:-
因此更改::-
$('.cancelbox').each(function(){ $(this).on('click',function(){至::-
$(document).on('click','.cancelbox',function(){所以代码需要是:
$(document).on('click','.cancelbox',function(){ $.ajax({ type : 'POST', url : 'menus/deleteTmp', data: { '_token' : $('input[name=_token]').val(), 'id' : $(this).data('menuid'), }, success : function ($data) { $('.item' + $data).remove(); } });});注意:-现在应用您的
replaceWith()代码并检查



