Remove anchor from URL on scroll

[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]
3 Comments
  1. $(‘a[href^=”#”]’).click(function(){
    setTimeout(() => {
    window.history.replaceState({}, “”, window.location.href.split(“#”)[0]);
    }, 100);
    });

  2. 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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer