开发者

How do I make the window scroll on mousedown, using jQuery?

开发者 https://www.devze.com 2023-04-03 11:58 出处:网络
I was just wondering why this isnt working: $(\'#down-a-bit\').mousedown(function(){ setTimeout( $(\'html, body\').animate({ scrollTo开发者_开发技巧p: $(this).offset().top += 1}) ,300);

I was just wondering why this isnt working:

$('#down-a-bit').mousedown(function(){
    setTimeout( $('html, body').animate({ scrollTo开发者_开发技巧p: $(this).offset().top += 1}) ,300); 
});

What am I doing wrong? Any help would greatly be appreciated, Thanks


You can use .delay instead of setTimeout. If you use setTimeout, wrap it in a function.

http://jsfiddle.net/pMTsF/

0

精彩评论

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