How can be Google Chrome prevented from jumping to the top when removing these clases/unhiding elements, this doesn’t happen on Firefox… and I need both functions: to remove the class from the elements, that is unhiding them and to scroll to the title in question from the link. without unhiding items the scroll works fine, and with both unhiding works but then the scroll is not properly working…
Tried using scrollintoview method as well as scrolltop to compensate this with no success.
Ok I have tried to simplify the code so no working codepen yet I’m afraid…
- Event listener on click from an anchor
linkItem[z].addEventListener('click', clearFilters, false );
- Attached function
function clearFilters(event) {
//set here a timeout so I can tell when the jump happens after unhiding
const timeoutID1 = setTimeout(() => {
const headings= document.querySelectorAll('h2, h3, h4, h5, h6');
for (var e = 0; e < headings.length; e++) {
headings[e].classList.remove("d-none");
}
,2000);
}