[ad_1]
Hi guys,
I am working on a WordPress site using elementor where I decided to use buttons which scroll to id. These however add an anchor to the URL. That means that when I reload the scroll animation immediately starts and wherever I am on the page it scrolls from that spot to the element with the id. Is there a way to remove the anchor from the url after pressing the scroll button?
[ad_2]
Im Sure this work with jquery or Javascript.
$(‘a[href^=”#”]’).click(function(){
setTimeout(() => {
window.history.replaceState({}, “”, window.location.href.split(“#”)[0]);
}, 100);
});
Why is this a problem? It’s designed that way. It won’t affect anyone else unless they randomly decide to reload the page after clicking the anchor link. Just delete the hash from the url.