jquery : detecting scroll position

本小妞迷上赌 提交于 2019-11-27 14:18:52

Working DEMO

Try this

$(window).scroll(function () {

    if ($(window).scrollTop() + $(window).height() > $('.footer').offset().top) {
        alert("footer visible");
    } else {
        alert("footer invisible");
    }
});

Hope this helps,Thank you

There is a jquery plugin for this task named jQuery Waypoints (http://imakewebthings.com/jquery-waypoints/)

$('#footer').waypoint(function(direction) {
    alert('Top of thing hit top of viewport.');
});

here is a working fiddle... http://jsfiddle.net/kasperfish/JRUnr/14/

it is hacked together but it works

        flag=true;


$(window).scroll(function() {
    st=$(window).scrollTop();
    $('#topscroll').html(st)


    if(st>1450){
        if(flag)
        alert('test');flag=false;
    }

});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!