Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery-侦听元素删除活动_Jquery_Live - Fatal编程技术网

jQuery-侦听元素删除活动

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.'); }; $('

是否可以使用jQuery live事件侦听DOM中的元素删除

我需要像这样的东西:

$('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

不幸的是,这并不能解决我的问题。我想做一个通用的监听器来处理所有删除的元素(以标准方式),而不是手动破解原始代码。不幸的是,这并不能解决我的问题。我想做一个通用的监听器来处理所有删除的元素(以标准方式),而不是手动破解原始代码。