Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140220

Onscroll toggle failing to add or remove class

$
0
0

I am fairly new to js but I am trying to get this to fire so that my nav div will stick to the top of the screen I am not sure if my window on scroll function is firing correctly.

    $(document).ready(function(){   
    "use strict";   

    $('#commons').window.onscroll(function(direction) { 
    $('.main-nav').toggleClass('fixed-nav', direction == 'down');
    $('.main-nav a').removeClass('active');
    $('.main-nav a.commons-btn').addClass('active');
}, { offset:'90px' });
});

Viewing all articles
Browse latest Browse all 140220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>