title: How to scroll to first row during pagination in jQuery DataTables
body: <p>I am new to DataTables and i am using it in order to display the contents which I am getting from the database.</p>
  
  <p>I am not able to scroll to the top of the page or to the first row when I click on pagination buttons from the bottom of the page.</p>
  
  <pre><code>$.ajax({
  contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
  type: "GET",
  url: "xyz",
  data: dataString,
  async: "false",
  datatype: "json",
  success: function(response) {
  
         writeResultTable();
         var obj = parseJSONfromSearch(response);
  
         $('#tableId').DataTable( {
              data: obj,
              "bJQueryUI": true,
              "bPaginate" : true,
          "sPaginationType" : "simple",
          "bServerSide": false,
          "fixedHeader": true,
              columns : [
                         { "targets": [0],
                             "sortable" : true,
                              "render":function(data, type, full, meta){
                                 return '&lt;a href="'+full.url+'" target="_blank"&gt;' + full.TitlePath + '&lt;/a&gt;' + "&lt;br\&gt;" + "&lt;br\&gt;" +                                                                                                                                                                                  full.Description;
  
                              }}
  
                     ],
                     "sDom" : '&lt;"top"l&lt;"divline"ip&gt;&gt;rt&lt;"bottom"&lt;"divline"ip&gt;&gt;&lt;"clear"&gt;',
              "sAutoWidth" : true,
               "fnDrawCallback": function(o) {
  
                      moveToTop();
  
  
  
            } 
      } );
  </code></pre>
  
  <p>},</p>
  
  <pre><code> error: function(response, status, error ) {
        alert("error123");
        alert(status);
        alert(error);
  
    }
  });
  
  function moveToTop(){
  window.scrollTo(0, 0);
  }
  </code></pre>
  
  <p>I tried several things like below but nothing works: -</p>
  
  <pre><code>function paginateScroll() {
  $('html, body').animate({
  scrollTop: $(".dataTables_wrapper").offset().top
  }, 500);
  console.log('pagination button clicked');
  $(".ui-button").unbind('click', paginateScroll);
  $(".ui-button").bind('click', paginateScroll);
  }
  paginateScroll();
  </code></pre>