元素"这个"在Chrome扩展程序弹出窗口中无法正常使用

时间:2018-04-11 03:33:45

标签: javascript jquery google-chrome-extension scroll this

我正在开发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弹出式环境中无法正常工作?”

0 个答案:

没有答案