开发者

How do I simulate a scrollbar click with jQuery?

开发者 https://www.devze.com 2022-12-28 09:33 出处:网络
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

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

精彩评论

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