There are at least two ways to resolve. Either:
- Add a parameter to your anchor tag’s click event and call the preventDefault function on it
OR
- Instead of an anchor tag, use a span tag or some other element with an inline-block display.
Why? Because when you put href="" in your anchor tag without preventing the default action (load a page), then it tries to load the same page again. A blank string for href is the same as putting in the same web page name. Using the 2nd solution above, you avoid needing to prevent any default functionality, because span elements do not have any functionality.