Friday, 23 May 2014

Scroll function in HTML

/*Scroll FunctionIn HTML */

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Scroll to Bottom or Top - DevCurry.com</title>
    <script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js">
    </script>
     <script type="text/javascript" language="javascript">
         $(function () {
             $('#scrlBotm').click(function () {
                 $('html, body').animate({
                     scrollTop: '1000px'
                 },
                 1500);
                 return false;
             });
$('#scrlmid').click(function () {
                 $('html, body').animate({
                     scrollTop: $(document).height()
                 },
                 700);
                 return false;
             });

             $('#scrlTop').click(function () {
                 $('html, body').animate({
                     scrollTop: '0px'
                 },
                 1500);
                 return false;
             });

         });
    </script>
</head>
<body>
    <a id="scrlBotm" href="#">Scroll to mid</a>
    <div style="height:1500px"></div>
<a id="scrlmid" href="#">Scroll to Bottom</a>
    <div style="height:1000px"></div>
    <a id="scrlTop" href="#">Scroll to Top</a>
</body>
</html>

No comments:

Post a Comment