我正在开发Chrome扩展程序的弹出窗口。我将div
的滚动事件中的回调绑定到这样的选择器:
$('#activity-tab .activity-list').bind('scroll', () => {
if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight){
// My code goes here
}
);
但它将this
解释为弹出窗口中的Window
,而不是选择器本身的元素。我必须将我的代码更改为使其正常工作:
但是
$('#activity-tab .activity-list').bind('scroll', () => {
let element = $('#activity-tab .activity-list');
if (element.scrollTop() + element.innerHeight() >= element[0].scrollHeight){
// My code goes here
}
);
为什么“{1}}在Chrome弹出式环境中无法正常工作?”