1. 程式人生 > >JS jQuery滾動條下拉到底觸發事件

JS jQuery滾動條下拉到底觸發事件

var edit=true;//可控元素
        $(window).scroll(
                function () {
                    var scrollTop = $(this).scrollTop();
                    var scrollHeight = $(document).height();
                    var windowHeight = $(this).height();
                    if (scrollTop + windowHeight+100 >= scrollHeight && edit) {
                        edit=false;
                        console.log(“來,跟著一起。哈哈哈哈哈哈”);
                        setTimeout("edit=true;",1000);
                    }else{
                        console.log(scrollTop);
                        console.log(windowHeight);
                        console.log(scrollHeight);
                    }
                }
        );