Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

Javascript - Can I make this table scroll to top?

$
0
0

I have to make a self-scrolling table. I tried using this: https://codepen.io/salman31/pen/dYdGLa

    var my_time;
$(document).ready(function() {
  pageScroll();
  $("#contain").mouseover(function() {
    clearTimeout(my_time);
  }).mouseout(function() {
    pageScroll();
  });
});

function pageScroll() {  
    var objDiv = document.getElementById("contain");
  objDiv.scrollTop = objDiv.scrollTop + 1;  
  $('p:nth-of-type(1)').html('scrollTop : '+ objDiv.scrollTop);
  $('p:nth-of-type(2)').html('scrollHeight : ' + objDiv.scrollHeight);
  //if (objDiv.scrollTop == (objDiv.scrollHeight - 50)) {
    objDiv.scrollTop = 0;
  //}
  my_time = setTimeout('pageScroll()', 25);
}

And it works, but it doesn't automatically scroll back to top when it hits the "bottom". What do I need to change?

Thank you!


Viewing all articles
Browse latest Browse all 67497

Trending Articles