javascript - Highlighted menu items are highlighting too early in a parallax effect -


i'm trying build website parallax effect , dynamically highlighted menu items.

for moment works fine (parallax , menu items) combined menu items strange behaviour. highlighted early, menu items swap 'home' 'company' on beginning of 'home' site , on.

this js code using

$(document).ready(function() {     $('.parallax').scroll(function() {          var position = $(this).scrolltop();          $('.parallax__group').each(function() {              var target = $(this).offset().top;             var id = $(this).attr('id');              if (position >= target) {                 $('a').removeclass('active');                 $("a[href='#"+id+"']").addclass('active');             }         });     }); }); 

as said... it's working menu items not highlighted when reaches new group, way earlier. source of problem? can provide more code if needed.


Comments