tags:

views:

60

answers:

2

How do I simulate a scrollbar click with jQuery? So, if a user clicks on a div that says "scroll down," it'll be the exact same behavior as if he/she clicked on the down arrow of the browser's scrollbar. Using the current browser's behavior would be optimal, vs. doing something like $.browser.scrolldown(200,'fast').

Something like $.browser.triggerDownArrowOnScrollBar() would be sweet!

+1  A: 

Do you mean that you want to scroll to different points on the page? This can be done like this:

$.scrollTo('#your-div');

Using: http://flesler.blogspot.com/2007/10/jqueryscrollto.html

-

If you want to find when the user scrolls, you can use:

$(window).scroll(function() {
  // your actions here
});
Tim
A: 

By the sounds of it, you just want to scroll the page up/down by a fixed amount:

/* Scroll down 10px */
$.scrollTo($(window).scrollTop()-10);

/* Scroll up 10px */
$.scrollTo($(window).scrollTop()+10);
James
This is helpful! I'm actually looking to avoid fixed amounts, but use whatever the browser uses for scrolling up and down. Firefox might do 10 px, but Safari might do 15px...
Ian Davis