HOME / BLOG / BLOG-POST

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

Scroll to top on click and change color after scrolling some length by jquery
//jquery used
$(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);
     } 

 


about authors

Sandip Das

Web Developer

Once a legend said “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler.



POST COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *