0

In this example all things work nice, but when scrolling in large window width then resize it to small window the div still take the .fixed class

So it's working just when the scroll is 0px(top), but not when resizing the window to a small size while scroll it more than 0px

I want it to remove the .fixed class when detecting scroll 0 and window is less than 600px even if the document is already loaded

Example: http://jsbin.com/arehow/1/edit

4

1 回答 1

2

你的条件不对。

if ( $(window).width() > 600 ) {
            $('div').addClass('fixed');
        }
    } else {
        if ( $(window).width() > 600 ) {
            $('div').removeClass('fixed');
        }
    }

两个条件都 >600 ... 使最后一个条件为 < 600

于 2013-04-18T11:02:10.700 回答