开发者

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

开发者 https://www.devze.com 2023-03-25 09:30 出处:网络
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 wor

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

精彩评论

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

关注公众号