I am trying to make my page scroll when you hover on a div. This is what I got so far
$(document).ready(function() { $("#hoverscroll").mouseover(function() { var div = $('body'); setInterval(function(){ var pos = div.scrollTop(); div.scrollTop(pos + 1); }, 100) }); }); However, there are two things left to do. I need it to increase speed each time you click, stop when you're no longer hovering and reset the speed back to default.
I'm trying to achieve something like this:
$(document).ready(function() { $("#hoverscroll").mouseover(function() { var div = $('body'); setInterval(function(){ var count = 1; var pos = div.scrollTop(); div.scrollTop(pos + count); }, 100) }); $("#hoverscroll").click(function() { if (count < 6) { count = count+1; } }); $("#hoverscroll").mouseleave(function() { count = 0; }); }); I searched and found some people talking about binding event and setting a global variable to check if it's scrolling. But will the above function work? I am still learning. I might be completely wrong.