I am hoping someone will have some insight into my jQuery conundrum. I’m trying to implement a fairly simple script to add/remove a class to my navbar. I’ve mocked up a codepen here: http://codepen.io/anon/pen/Inmpb On scrolldown, a class is added to the navbar, so that I can target it. It works as expected on codepen, but I cannnot get it to work on my dev site. For the codepen, I simply copied and pasted the entirety of my html and css and then added my script and, there, it worked as expected.

I have tried wrapping the script in the document ready function for wordpress: jQuery(document).ready(function($) { // function here });

I have tried adding the script directly to the footer. I have tried to enqueue it via functions.php. It simply doesn’t work on my site.

I have checked the console and no errors. I’ve also tried all of the noConflict wrappers found here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers (using only JQuery, using jQuery and “$” in function, etc.)

I also changed to twenty-fourteen and deactivated all plugins. Still no luck. However, I did try an even more simple script: http://pastebin.com/XJh2Bbvm and that did work, the class was added.

I have no idea what I could be missing.

Read more here: pageYOffset problems in WordPress? Works on code playground, not on dev site


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , ,

Wordpress related questions and answers: