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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -