0

我继续在 Uncaught TypeError 的主页上收到错误:无法使用此代码读取 null 的属性“顶部”。

// Load Carousel on Scroll.
$(window).scroll(function () {
    $loadedContainer = $('.pane-idevels-browse-genres-custom-content-load .pane-content');
    offsetY = $loadedContainer.offset().top;
    cH = $loadedContainer.outerHeight();
    wH = $(window).height();
    bodyScroll = $('body').scrollTop();
    htmlScroll = $('html').scrollTop();
    scrollTop = (bodyScroll == 0) ? htmlScroll : bodyScroll;
    carouselOffset = offsetY + cH;
    windowOffset = wH + scrollTop;
    if (carouselOffset <= windowOffset) {
        loadCarouselGenres($loadedContainer)
    }
})
4

2 回答 2

0

尝试这个:

$(window).scroll(function () {
    $loadedContainer = $('.pane-idevels-browse-genres-custom-content-load .pane-content');

    if($loadedContainer){

       offsetY = $loadedContainer.offset().top;
       cH = $loadedContainer.outerHeight();
       wH = $(window).height();
       bodyScroll = $('body').scrollTop();
       htmlScroll = $('html').scrollTop();
       scrollTop = (bodyScroll == 0) ? htmlScroll : bodyScroll;
       carouselOffset = offsetY + cH;
       windowOffset = wH + scrollTop;
       if (carouselOffset <= windowOffset) {
         loadCarouselGenres($loadedContainer)
       }
    }
});
于 2013-10-24T04:25:32.590 回答
0

可能 jQuery 在本节中找不到元素

$('.pane-idevels-browse-genres-custom-content-load .pane-content');
于 2013-10-24T03:35:25.213 回答