0

I'm trying to change a class based on how far from the top of the document the window is, and when it's greater then a certain value to make the switch, for some reason it's not happening, this is what I have so far:

$(window).scroll(function() {

    if ($('html, body').offset.top > ($("#top_section").outerHeight(true) + $("#grid").outerHeight(true))) { 
        $(".nav_middle_text").removeClass("selected");
        $(".nav_middle_text").addClass("notselected");
        $("#about_link").removeClass("notselected");
        $("#about_link").addClass("selected");    
    } 

});
4

2 回答 2

2

去吧,

$(window).scroll(function() {
    var scroll = $(window).scrollTop();
    if (scroll >= ($("#top_section").outerHeight(true) + $("#grid").outerHeight(true))- 70) { 
        $(".nav_middle_text").removeClass("selected");
        $(".nav_middle_text").addClass("notselected");
        $("#about_link").removeClass("notselected");
        $("#about_link").addClass("selected");    
   } 

});
于 2013-01-10T21:56:02.983 回答
0
$(window).scroll(function() {

    if ($(window).scrollTop() >= 50 ) {

        $('.floating-header').addClass('hide');
        $('.fixed-header').addClass('fixed');

    } else {

        $('.floating-header').removeClass('hide').addClass('show');
        $('.fixed-header').removeClass('fixed');
    }
});
于 2015-06-17T12:30:43.377 回答