I have encountered an error with my website where Javascript functions improperly on the localhost environment.
I have previously encountered a similar problem with image loading (solved), which I have posted about in this thread: Images not loading in local host
The website is the same. The problem arises from a function that involves “mouseenter” and “mouseleave” events, and changing the colors of certain divs. When the mouse enters a div, its color changes to a generated random color, and returns to its standard color upon leaving. The problem in this case is that the whole function operates with bugs.
I am assuming that it is the localhost/Kirby since when I run the code purely from Visual Studio Code (HTML, CSS, JavaScript), the error does not occur, and the JavaScript and CSS were copied directly from the vanilla version.
The console doesn’t provide anything, there are no loading/syntax errors.
That’s certainly not a problem with Kirby and since the highlighting seems to work in general, maybe it’s some sort of markup issue (maybe duplicate ids or so=.
Here is the structure that I am using, the problem arises when targeting .container and creating spans with Javascript in .Page and the paragraphs in .Info, the rest of the functions work as intended, including the swiper and toggle.
I was trying to find duplicate ID-s in console, but no luck with that.
This element exists multiple times (once foreach element in the loop), so depending on what you do in your JS, this will affect all elements of this class. But again, not a Kirby problem.