Reputation: 7599
i'm having a div with lots of content and a vertical scrollbar. i'd like to replace the scrollbar with an up/down button in order to scroll the content on hovering the buttons. any ideas how to do this? thanks
Upvotes: 2
Views: 3007
Reputation: 5316
Try scrollTop()
var timeoutId = 0;
function scrollIt(amount){
$('div').scrollTop($('div').scrollTop()+amount);
}
$('.down').mousedown(function() {
timeoutId = setTimeout(scrollIt(5), 1000);
}).bind('mouseup mouseleave', function() {
clearTimeout(timeoutId);
});
$('.up').mousedown(function() {
timeoutId = setTimeout(scrollIt(-5), 1000);
}).bind('mouseup mouseleave', function() {
clearTimeout(timeoutId);
});
Upvotes: 3
Reputation:
I think based on this, you'll get a pretty good start on how to do this.
http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12
Upvotes: 1
Reputation: 872
I think this plugin might be helpful: http://www.kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html
Upvotes: 1