Do something when page is scrolling and have some position

时光毁灭记忆、已成空白 提交于 2020-01-13 00:03:10

问题


i have a little problem with page scrolling... I wanna to change some css when i'm scrolling page down and if window have 100px from top position... This is my code. Much thx for help.

$(document).ready(function(){
    $(window).scroll(function(){
        if ($(window).scroll(100)){
            $('.ufo').css('right','800px');
        }
    });
});

回答1:


Try this:

$(document).ready(function(){
    $(window).scroll(function(){
        if ($(window).scrollTop() > 100){
            $('.ufo').css('right','800px');
        }
    });
});


来源:https://stackoverflow.com/questions/10994909/do-something-when-page-is-scrolling-and-have-some-position

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