title: Pagination- Scroll to Top
body: <p>I'm currently utilizing pagination with the following code. I'm searching for a way to make the page scroll to the beginning of the list of content on page switch. <a href="http://sneakerwire.net/news.html" rel="nofollow">Example of page here.</a> Any help would be very much appreciated, thanks!</p>
  
  <pre><code>(function($){
  
     $.fn.customPaginate = function(options)
     {
         var paginationContainer = this;
         var itemsToPaginate;
  
  
         var defaults = {
  
              itemsPerPage : 4
  
         };
  
         var settings = {};
  
         $.extend(settings, defaults, options);
  
         var itemsPerPage = settings.itemsPerPage;
  
         itemsToPaginate = $(settings.itemsToPaginate);
         var numberOfPaginationLinks = Math.ceil((itemsToPaginate.length / itemsPerPage));
  
         $("&lt;ul&gt;&lt;/ul&gt;").prependTo(paginationContainer);
  
         for(var index = 0; index &lt; numberOfPaginationLinks; index++)
         {
              paginationContainer.find("ul").append("&lt;li&gt;"+ (index+1) + "&lt;/li&gt;");
         }
  
         itemsToPaginate.filter(":gt(" + (itemsPerPage - 1)  + ")").hide();
  
         paginationContainer.find("ul li").on('click', function(){
  
             var linkNumber = $(this).text();
  
              var itemsToHide = itemsToPaginate.filter(":lt(" + ((linkNumber-1) * itemsPerPage)  + ")");
              $.merge(itemsToHide, itemsToPaginate.filter(":gt(" + ((linkNumber * itemsPerPage) - 1)  + ")"));
              itemsToHide.hide();
  
              var itemsToShow = itemsToPaginate.not(itemsToHide);
              itemsToShow.show();
         });
  
     }
  
  }(jQuery)); 
  </code></pre>