scroll up button

How to make scroll up button in angularjs?

When we are working with web site we are moving along different pages. When we are going bottom of the page, to come again on top we need to scroll using scroll bar. Instead of this we have to place a button at the bottom and on clicking it will directly place you on the top of the page without touching scroll bar.


HTML Code:

<button onclick=”topFunction()” id=”myBtn” title=”Go to top”><img src=”/assets/Images/TopArrow.png” style=”height:20px;width:20px;cursor:pointer”/></button>

JS Code:

  function topFunction() {

            document.body.scrollTop = 0;

            document.documentElement.scrollTop = 0;



Here when we click the button it will call the function and move the page to top. Below image showing the arrow at right corner, when you click it, it moves the page on top.