jQuery-侦听元素删除活动
是否可以使用jQuery live事件侦听DOM中的元素删除 我需要像这样的东西:jQuery-侦听元素删除活动,jquery,live,Jquery,Live,是否可以使用jQuery live事件侦听DOM中的元素删除 我需要像这样的东西: $('body').on('remove', '.selector', function() { console.log('Element removed.'); }); 但它不起作用:(可能是您正在寻找的: $.fn.customRemove = function () { $(this).remove(); console.log('Element removed.'); }; $('
$('body').on('remove', '.selector', function() {
console.log('Element removed.');
});
但它不起作用:(可能是您正在寻找的:
$.fn.customRemove = function () {
$(this).remove();
console.log('Element removed.');
};
$('.selector').customRemove(); // you will get the log automatically
也许你想要的是:
$.fn.customRemove = function () {
$(this).remove();
console.log('Element removed.');
};
$('.selector').customRemove(); // you will get the log automatically
不幸的是,这并不能解决我的问题。我想做一个通用的监听器来处理所有删除的元素(以标准方式),而不是手动破解原始代码。不幸的是,这并不能解决我的问题。我想做一个通用的监听器来处理所有删除的元素(以标准方式),而不是手动破解原始代码。