window.onscroll = function (ev) {
        //console.log("距离顶部的高度:"+$(document).scrollTop());
        var heightY = $(document).scrollTop();
        var x = $(document).scrollLeft();
        if(heightY > 0){
            console.log("距离顶部的高度:"+heightY);
            $("#threadId").css("position","fixed");
        }
        if(x > 0 ){
            console.log("距离左边:"+x);
            $("#threadId").css("position","static");
        }
    }

  滚动条滚动时,发生的事件

posted on 2019-10-16 09:07  lazyli  阅读(653)  评论(0编辑  收藏  举报