JS not working as expected

I’m having trouble in the Content JS section.

I want the logo in the menu to change classes when it scrolls to the top.

i find it will work in the editor but not in the front end.

https://adamnet.works/dnsharmony

(function) {
var menu = (".menu-item-282");
(window).scroll(function() {
var scroll = $(window).scrollTop();
console.log(“got here!!”);
if (scroll >= 500) {
menu.removeClass(“menu-logo-grey”).addClass(“menu-logo”);
} else {
menu.removeClass(“menu-logo”).addClass(“menu-logo-grey”);
}
});
};

Hi,

Please replace that code with this

jQuery( function($) {
    $(window).scroll(function(){
        if ( $(this).scrollTop() >= 500 ) {           
	   $('.menu-item-282').removeClass("menu-logo-grey").addClass("menu-logo");
	}
	else {
	   $('.menu-item-282').removeClass("menu-logo").addClass("menu-logo-grey");
	}
    });
});

Please add it in Theme Options > JS

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.