开发者

How do I simulate a scrollbar click with jQuery?

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!


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
});


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜