jQuery code not working
-
Hi, I’m trying to manually implement a sidebar element that becomes fixed after some scrolling. In order to do it, I’m using few lines of jQuery that after scroll add a class with position:fixed property to the element, and on a testing environment it works fine.
However when implementing it on wordpress, it doesn’t seem to work. I put the following script in the custom javascript section of my theme admin panel, it seems to be loaded on the frontend but nothing happens.$(window).scroll(function(){ if ($(this).scrollTop() > 235) { $('#sidebar-2').addClass('fix-it'); } else { $('#sidebar-2').removeClass('fix-it'); } });Here’s also some dummy code to explain what I’m trying to accomplish: fiddle
Am I missing something? Thanks for your help.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘jQuery code not working’ is closed to new replies.