0

I want to slowly fade out a div using JQuery when I start scrolling horizontally, and then Fade back in when I go back to 0 in the horizontal axis. So I have this:

    <div id="hider">Content</div>

And then the script:

    $(function() {
    $(document).scroll(function() {
    if($('body').scrollLeft() == 0)
    $("#hider").fadeIn();
    else 
    $("#hider").fadeOut();
    });
    });

and on the CSS

I have:

    #hider {
position: absolute;
left: 34px;
display: none;
    }

I saw this solution in a similar thread, but I can't get it to work.The div #hider just keeps blinking on and off as I scroll and never stops blinking

Thanks!

4

1 回答 1

1

您选择的是标签而不是 id:

这样做:添加#这样的:

$("#hider").fadeIn();

看到这个:http ://api.jquery.com/fadeIn/ 和 http://api.jquery.com/fadeOut/

请参阅内容以了解您要执行的操作。

于 2012-07-02T22:12:28.807 回答