Oct 25, 2014

Go To Top Of The Page Using JQuery Function

When You Have A Web Page With Lot Of Data That Mean, Need To Scroll Down To See All The Details Normally To Read The Top Details You Have To Scroll It Top Again.Rather Than Scrolling To Top You Can Use A Button To Scroll To Top Using JQuery Function. 

Simply Use Following Code To Do That

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


This Is A Simple Exam That Use Scroll Top Function.

<html>
   <head>
      <title>Easy Code Stuff - Scroll To Top Using JQuery</title>
      <script type="text/javascript" src="jquery.js"></script>
      <script>
         function goToTop() {
           $("html, body").animate({
              scrollTop: 0
           }, 600);
           return false;
        }
      </script>
   </head>
   <body>
      <h2>This Is The Top Of The Page</h2>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
      <br/><br/>
      <input type="button" value="Go To Top" onclick="goToTop()"/>
   </body>
</html>


No comments:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...