Remove the link ID when it is referenced with an href

0

I have a project of a template, in the footer of it has a button that leads to the top of the site, when it squeezes it leads to the top of the site but leaves the id "#top" in the site link (mysite / index. html # top), how can this not happen?

No body has an id named top:

<body id="top">

In the footer has a link where it leads to the top:

<a href="#top"> Voltar para o topo </a>
    
asked by anonymous 25.01.2018 / 14:06

1 answer

1

With CSS I believe it is not possible without tagging url , but as tagged the javascript tag, you can do this with a few lines of the language ...

function topFunction(){
    document.documentElement.scrollTop = 0;}
.scroll {
  background-color:black;color:white;padding:30px;
}
.example {
  background-color:lightgrey;padding:30px 30px 300px
}
.top {
  margin-top: 500px
}
<div class="scroll">Scroll Down</div>
<div class="example"> 

<button onclick="topFunction()" class="top">Top</button>

</div>
    
25.01.2018 / 15:05