Javascript menu navbar code doesn’t execute probably

I am currently working on a wordpress theme and I got a problem. I am trying to let te navbar move on scroll, but in the beginning he has to be under a slideshow. I have done the following:
1. Add an extra navbar with a fixed class, top: 0 and visibility hidden
2. I tried to make some javascript code that does the following:
– Calculate if the fixed navbar is at the same/lower position from the top as the normal navbar
– If the position is the same/lower set the visibility of the fixed navbar to vissible and the visibility of the normale menu to invisble.
My javascript code is:

var slider = document.getElementsByClassName("slider").offsetHeight;
var nav = document.getElementsByClassName("normal-navbar").offsetHeight;
var scroll = document.getElementsByClassName("fixed-navbar").offsetTop;
var combined = slider + nav;
if (combined =< scroll ) { 
    $('fixed-navbar').style.cssText = 'visibility: visible !important';
    $('normal-navbar').style.cssText = 'visibility: hidden !important';

Read more here: Javascript menu navbar code doesn’t execute probably

Leave a Reply

Your email address will not be published. Required fields are marked *