Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Auto Scrolling Page Using jQuery

Saturday, Jan 21, 2017

Tags:- jQuery HTML


In this tutorial we will show you how to scroll the webpage automatically using jQuery and HTML.We also provide auto scroll, manual scroll and stop scroll function to give full control to user and also to increase user experience.You may also like smooth scrolling to div using jQuery.


See Demo
Auto Scrolling Page Using jQuery


To Auto Scroll The Page It Takes Only One Step:-

  1. Make a HTML file and define markup, scripting and styling


Step 1.Make a HTML file and define markup, scripting and styling

We make a HTML file and save it with a name auto_scroll.html

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function page_scroll()
{
 $("html, body").animate({ scrollTop: $(document).height() }, 20000);
}
function stop_scroll()
{
 $("html, body").stop();
}
</script>
<style>
body
{
 text-align:center;
 width:100%;
 margin:0 auto;
 padding:0px;
 font-family:helvetica;
 height:1500px;
 background-color:#F3F781;
}
#wrapper
{
 text-align:center;
 margin:0 auto;
 padding:0px;
 width:995px;
}
#scroll
{
 position:fixed;
 left:40%;
 top:30%;
 width:100px;
 height:35px;
 border:1px solid #868A08;
 background:none;
 color:#868A08;
 font-size:16px;
}
#stop_scroll
{
 position:fixed;
 left:50%;
 top:30%;
 width:100px;
 height:35px;
 border:1px solid #868A08;
 background:none;
 color:#868A08;
 font-size:16px;
}
.scroll_text
{
 width:500px;
 border:1px solid #868A08;
 margin-left:235px;
 margin-top:180px;
 padding:10px;
 color: #868A08;
 font-size: 15px;
 line-height: 1.5em;
 word-spacing: 6px;
}
</style>
</head>
<body>
<div id="wrapper">

<div id="scroll_div">
 <input type="button" id="scroll" value="Scroll" onclick="page_scroll();">
 <input type="button" id="stop_scroll" value="Stop Scroll" onclick="stop_scroll();">
 <div class="scroll_text">
  This is a demo of Auto Scrolling Page Using jQuery On TalkersCode.com 
  This is a demo of Auto Scrolling Page Using jQuery On TalkersCode.com
 </div>
</div>

</div>
</body>
</html>

In this step we create two buttons one for scroll the page automatically and other is used to stop the scrolling of the page.We add jquery.js file to scroll the page and we also create two functions page_scroll() and stop_scroll(). page_scroll() function is used to scroll the page using jquery animate() function and in stop_scroll() function we simply stop the scrolling when user don't want to auto scroll the page.You may also like page scroll to top using jQuery.



Thats all, this is how to auto scroll the page using jQuery.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH

Check Out SEMRUSH