0

sorry for reposting this question, I don't think I was clear in my other post.

I want to make a scroll to the top animation link, like the link at the bottom of this website, http://www.thechrisellefactor.com/

How would I go about doing/code this? I don't have much experience in coding just as a heads up, I'm learning as I go :/

Fiona Chan
  • 21
  • 6

2 Answers2

0

Please check out this post

Scroll to the top of the page using JavaScript/jQuery?

<script>
$(document).ready(function(){
 $("button").click(function(){
    window.scrollTo(0, 0);
  });
});
</script>

HTML

  <button>Return To TOP</button>
Community
  • 1
  • 1
Anthony
  • 801
  • 10
  • 20
0

To animate and set how long the scroll takes you can do it like this

$('#btn').on('click', function(){
    $("body").animate({ scrollTop: 0 }, 1000);
}); 

Here is a JSFIDDLE showing it in action

akaBase
  • 2,178
  • 1
  • 18
  • 31