简体   繁体   English

$(window).bind不适用于加载了ajax的内容?

[英]$(window).bind not working for content loaded with ajax?

 $(window).bind('scroll', function(){ //when the user is scrolling...
  //some-code
  });

I face the same problem for click and I solved it this way: 我在点击时也遇到了同样的问题,并通过以下方式解决了这一问题:

$(document).on('click','#id',function(){
//some code
})

I dont know how to assign scroll action for content loaded with ajax. 我不知道如何为加载了ajax的内容分配滚动操作。

http://www.arrowlife.com/index-v3 http://www.arrowlife.com/index-v3

try calling the function again after the ajax call 尝试在ajax调用之后再次调用该函数

  $.ajax({ 
      //some code   
  }).done(function(){   
      //scroll function 
  });

I think the issue is that you are calling the function before the element exists and therefore is not working properly. 我认为问题在于您在元素存在之前就调用了该函数,因此无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM