简体   繁体   English

jQuery:将滚动事件绑定到动态加载的内容

[英]jQuery: Binding Scroll Event to dynamically loaded content

I've been developing an application recently which uses the vertical scroll bar extensively for its UI. 我最近一直在开发一个应用程序,该应用程序将UI广泛使用垂直滚动条。 I've been using jQuery to do a lot of my work but recently I've hit a bit of a speed bump. 我一直在使用jQuery完成很多工作,但最近我遇到了一些减速。

All of my content is being loaded in dynamically, including the div which will have the scroll bar. 我所有的内容都是动态加载的,包括将具有滚动条的div。 Binding .scroll to that specific div does not do anything. 将.scroll绑定到该特定div不会执行任何操作。 I've tried multiple approaches through closure functions, using .on and .live but none seem to work. 我已经尝试过使用.on和.live通过闭包函数使用多种方法,但是似乎都没有用。

Has anyone had this problem before? 有人遇到过这个问题吗?

而是将其绑定到文档:

$(document).on('scroll', '#divId', function() { /* ... code ... */ });

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

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