猿问

jq scroll绑定问题

$(window).scroll(function(){

    var documentTop = $(document).scrollTop();

    var windowHeight = $(window).height();

    var documentHeight = $(document).height();

    //var txt = "windowHeight:"+windowHeight + " |*$*| documentTop:"+documentTop + " |*$*| documentHeight:"+documentHeight;

    //当 documentTop >= (documentHeight-windowHeight) 说明滚动条已经滚动到底部了

    if(documentTop >= (documentHeight-windowHeight)){

    console.log("加载");

        var tableTxt = $("#table").html();

        $("#txt").append("<hr>" + tableTxt);

    }

    

})

今天用这段代码在自己电脑上面和工作机上面运行都没问题,scroll生效,但是放到项目里面没法生效,debug js代码的时候,发现进不去$(window).scroll(function(){这个函数。有哪位大神遇到过这种问题,了解里面的机制的求解答一下,多谢。

开满天机
浏览 808回答 1
1回答

慕尼黑的夜晚无繁华

我建议尝试一下&nbsp;$(document).scroll()
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答