I’m building a WordPress/Bootstrap site, and am trying to use jquery to add a “fixed” class to the navbar when the user scrolls past it:

<script>
jQuery(document).ready(function($) {
$(function () {
    $(document).on( 'scroll', function(){
        console.log('scroll top : ' + $(window).scrollTop());
        if($(window).scrollTop()>=$(".rev_slider_wrapper").height())
        {
             $(".navbar").addClass("navbar-fixed-top");
        }
        if($(window).scrollTop()<$(".rev_slider_wrapper").height())
        {
             $(".navbar").removeClass("navbar-fixed-top");
        }
    });
});
});

Jquery is working fine - I’ve tested with a simple alert event, etc.
However, I’ve tried for a while and can’t get a window scroll event like this to work no matter what I do. I’m not getting any console errors. Can anyone help?

The test site is at http://www.chuckagency.com/wordpress-new.

Read more here: Jquery Window Scroll Event Not Working - WordPress / Bootstrap


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: