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?
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?
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>