How to scroll to top on click and change color after scrolling some length by jquery?

Scroll to the top on click and change color after scrolling some length by jquery


 


//jQuery code
$(window).scroll(function(){
var scrollval = $(window).scrollTop();
if(scrollval > 652)
{
$(".scroller").css("color","white");
}
if(scrollval < 652){
$(".scroller").css("color","");
}
});
$(".scroller").click(function(){
$(window).scrollTop(0);
});
    // html used 

        <div class="scroller">
      Tap to scroll up
</div>
<div class="jtset">
jtest
</div>

    //css used

        div .jtset{
background:blue;
height:500px;
width:auto;
padding:50px;
       }
       div .scroller{
       background:;
       color:black;
       width:200px;
      position: fixed;
       top:300px;
       left: 10px;
      -ms-transform: rotate(270deg); /* IE 9 */
      -webkit-transform: rotate(270deg); /* Safari 3-8 */
       transform: rotate(270deg);
      }