0

I use a simple arrow at the end of my page to link back to the to of the page

<a class="arrow-up" href="#menu-tophomesitemapsearchlanguageswitcher"></a>

If the user clicks on that arrow the page goes to Top as wanted, because the element with the id #menu-tophomesitemapsearchlanguageswitcher is in the Header.

But you can see it in the Browser ULR URL/#menu-tophomesitemapsearchlanguageswitcher is there a way to hide that the id of the element where i did href to is appedned to my URL.

Just that the common user doesnt see it :)

Viktor Carlson
  • 989
  • 1
  • 13
  • 36

2 Answers2

2

Use jQuery:

jQuery('html, body').animate({ scrollTop: 0}, 'slow');

Combined it looks like this:

<a class="arrow-up" onclick="jQuery('html, body').animate({ scrollTop: 0}, 'slow');"></a>

Der Vampyr
  • 941
  • 1
  • 7
  • 13
0

Why not use some vanilla JS? E.g.:

<a href='#' onclick='event.preventDefault();document.body.scrollTop=0;'>To Top!</a>

Demo Fiddle

SW4
  • 69,876
  • 20
  • 132
  • 137