You’re showing your source code but have you checked what is happening on the buggy page?
Is the HTML code alright? Does it reference your JS code? Is the URL to your JS code correct?
If the HTML code seems outdated, you may have to clear the site/cache directory. I think Kirby only invalidate’s a page’s cache if the page’s content file was modified. If you modified some template or snippet, it might not be picked up and Kirby might serve a stale cached HTML.
If everything looks alright on this side, check that JS execution is working alright:
Are there errors in the JS console? Maybe another script is failing and halting script execution altogether.
Can you see the event listeners on their respective elements (you can see them as small “EV” buttons next to the element’s name in Firefox’s DevTools inspector… not yet in Chrome’s DevTools sadly)?
Are there errors happening when you click the buttons?
If your event handler functions are executed (check that with a console.log or adding debugger; in your function or adding a breakpoint in your browser’s DevTools), since you’re querying the DOM to retrieve some elements, you should check that you actually find the elements you’re interested in (again, you can use console.log or your browser’s debugger).
Thank you fvsch, checking the console.log in Firefox may have solved the problem!
I also had a piece of code in the navigation script referring to the caption element, that gave an error message. It wasn’t working anyway so I removed that