如何使用jquery或javascript删除附加到DocumentReady上的元素的功能

如何使用jquery或javascript删除附加到DocumentReady上的元素的功能,jquery,Jquery,这里的情况是,最初我使用img属性动态创建一个div,并动态设置它的源代码。在图像加载时,也会调用一些函数。稍后在某个时间点,如果我更改该特定div的图像源,将调用不需要的相同函数 $(function(){ // on doc ready I do this $('#inner').append("<div id='data-1'><img/></div>"); $('#data-1').find('img').attr('src', dataArr

这里的情况是,最初我使用img属性动态创建一个div,并动态设置它的源代码。在图像加载时,也会调用一些函数。稍后在某个时间点,如果我更改该特定div的图像源,将调用不需要的相同函数

$(function(){
// on doc ready I do this
  $('#inner').append("<div id='data-1'><img/></div>");
  $('#data-1').find('img').attr('src', dataArr['id'][1].img).load(function() {
    populateNavigationDots();
    $(".pagination span:first-child").addClass('swiper-active-switch');
  });// this works fine.
});
// later if I try to change the src attribute of the above image then the previous on     load functionality 'populateNavigationDots();' too works. How can I stop this
$('#data-1').find('img').attr('src','img/2.jpg');
$(函数(){
//准备好了吗
$('#inner')。追加(Use


在图像加载之后,我使用jquery off删除了加载事件处理程序


$(“#data-1”).find('img').off('load');

.off('load')
。要删除什么?使用load函数的方式有点奇怪。这是jQuery的ajax加载吗?我正在使用jQuery的图像加载函数回调
.off( events [, selector ] [, handler(eventObject) ] )