Lukas
Lukas

Reputation: 7734

Do something when page is scrolling and have some position

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');
        }
    });
});

Upvotes: 5

Views: 15539

Answers (1)

gdoron
gdoron

Reputation: 150303

Try this:

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

Upvotes: 17

Related Questions