Remove link ID when referenced with href

Asked

Viewed 107 times

0

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

No body has an id called top:

<body id="top">

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

<a href="#top"> Voltar para o topo </a>
  • You could edit your question by putting snippet of code so we can analyze?

1 answer

1


With CSS I believe that it is not possible without the marking of url, but how did you tag javascript, it is possible to do this with a few lines of 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>

  • I tested here, much fought! Taking advantage, can indicate me some javascript material for me ?

  • Of course, you can start with https://pt.slideshare.net/rodrigobranas/java-script-overview, the didactics are amazing and have the series on Youtube too, but it’s good to keep an eye out for ES6 that’s coming with everything when it comes to front-end, I’ve learned a lot about ES6, webpack, Babel, etc... at the School of net, so I can recommend it, it’s paid but it’s worth it :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.