How do I fade a div in/out on page scroll?

后端 未结 2 1126
半阙折子戏
半阙折子戏 2021-02-08 19:35

Here is the jsfiddle: http://jsfiddle.net/NKgG9/

I\'m basically wanting those pink boxes to be on show on page load as normal but as soon as a user scrolls down the page

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-08 19:57

    Very simple example: http://jsfiddle.net/a4FM9/2/

    var divs = $('.social, .title');
    $(window).scroll(function(){
       if($(window).scrollTop() <10 ){
             divs.stop(true,true).fadeIn("fast");
       } else {
             divs.stop(true,true).fadeOut("fast");
       }
    });​
    

提交回复
热议问题