This might sound dumb, but are you sure the link isn’t just a `#`? Empty hashes can cause page reloads.
Try this:
```js
document.querySelectorAll('a').forEach(link => {
link.addEventListener('click', e => {
if (link.getAttribute('href') === '#') {
e.preventDefault();
}
});
});
```
If that doesn’t help, maybe share a snippet of your code?
Try this:
```js
document.querySelectorAll('a').forEach(link => {
link.addEventListener('click', e => {
if (link.getAttribute('href') === '#') {
e.preventDefault();
}
});
});
```
If that doesn’t help, maybe share a snippet of your code?
