Home › Forums › Other › Jquary navbar change when section (DIV) is view-able in window › Reply To: Jquary navbar change when section (DIV) is view-able in window
March 6, 2018 at 12:19 am
#267909
Participant
From a first glance at the top bit of code, .css
doesn’t do anything and should give a error:
$('.header').css.offset().top;
This is the correct format:
$('.header').offset().top;
The code at the bottom won’t work because of if else
– that should say else if
…
Edit – multiple errors here as well:
if (scrollPos >= top1 && scrollPos = top2 && scrollPos = top3) {
This condition won’t ever be true unless top2
and top3
have the same value. Besides that, comparison syntax is different:
if (scrollPos >= top1 && scrollPos == top2 && scrollPos == top3) {
Some purists would suggest to even use scrollPos === top2
.