Shortcut home button to upload the site? [duplicate]

0

I have a website, and the client asked that when I clicked the home button the site would go up completely. How do I do it?

    
asked by anonymous 26.10.2017 / 12:56

1 answer

0

Using Jquery

//scroll normal
$('html,body').scrollTop(0);

//scroll suave
$('html, body').animate({scrollTop:0}, 'slow'); //slow, medium, fast

Using Javascript

var scrollTop = function() {
    window.scrollTo(0, 0);
};
  

Suggestion of Francis Vagner of Light

HTML pointed to href of the link to the page snippet that is at the top:

<span id='topo'></span>

<p>
  bla bla <br> bla bla <br> bla bla <br> 
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
  bla bla <br> bla bla <br> bla bla <br>
</p>

<a href='#topo'>Voltar ao topo</a>
    
26.10.2017 / 13:14