How to create scroll to top of the page by jquery animate ?

How to create scroll to top of the page by jquery animate ?

In this post we will give you information about How to create scroll to top of the page by jquery animate ?. Hear we will give you detail about How to create scroll to top of the page by jquery animate ?And how to use it also give you demo for it if it is necessary.

However you want the scrolling process to have animated effect. you have to follow bellow example. in this post you can add button for scrolling top with animate effect. Most of website you can see with one button left side or right side for scrolling top of the page. so, if you want to create on your site then you have to add following jquery code:

Example

<style type="text/css">

#toTopImg{

position: fixed;

bottom: 20px;

left: 20px;

cursor: pointer;

display: none;

z-index: 999999;

background: #5a5a5a none repeat scroll 0 0;

display: block;

padding: 12px 15px;

}

</style>

<script type="text/javascript">

$(document).ready(function(){

$('body').append('<div id="toTopImg" style="display:none">Top</div>');

$(window).scroll(function () {

if ($(this).scrollTop() != 0) {

$('#toTopImg').fadeIn();

} else {

$('#toTopImg').fadeOut();

}

});

$('#toTopImg').click(function(){

$("html, body").animate({ scrollTop: 0 }, 600);

return false;

});

});

</script>

Hope this code and post will helped you for implement How to create scroll to top of the page by jquery animate ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

  +  9  =  11

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US