jquery - Toggle class depending on the div -


how toggle class on div element depending on user on screen.

eg- if user scrolls past div block class '.dark', active class '.active' should toggled on header element.

i have following code works single instance of '.dark'.

jquery(document).ready(function(){ var hieghtthreshold = $(".dark").offset().top; var hieghtthreshold_end  = $(".dark").offset().top +$(".dark").height() ;     $(window).scroll(function() {         var scroll = $(window).scrolltop();         if (scroll >= hieghtthreshold && scroll <=  hieghtthreshold_end ) {             $('header').removeclass('active');         }         else {             $('header').addclass('active');         }     }); }); 

however work one. i'm trying achieve multiple '.dark' classes on page.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -