开发者

Hide Div When Window X Position is past 1700px - jQuery

I am working on 开发者_JS百科a single page horizontal scrolling site that is 10,000 px wide and have a fixed position div that I only want to show with-in the first 1700 px of my site. So in other words when the windows x position is at 1700 px or greater I want the div to hide. How can I do this with jQuery? Thanks


Try something like this:

$(document).ready( function() {
    $(window).scroll( function() {
        if ($(window).scrollLeft() > 1700)
            $('#targetDiv').hide();
        else
            $('#targetDiv').show();
    } );
} );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜