I have created a small javascript file and linked into the sheet, the javascript triggers a class change in nav menu together with css changes the menu size and colour when you scroll from the top of the page.
It works fine when running the html files but when I export to wordpress the javascript is not working.
I have checked the function.php and the javascript file is linked.
Hi @stevegun1975,
Just a check on one thing - when you say the javascript file is linked, you mean it is enqueued, correct? You can see it loaded onto the end page?
That aside, if we assume your script is being loaded you are going to run into a problem with jQuery. Your script above isn’t in plain JS. In WordPress, jQuery uses “compatibility” mode. This means that you can’t use the $ shortcut directly like you are in this example. Instead, one approach is to change all of the $ intojQuery.
Another, probably better, approach is to wrap your script in a ready function.