Nasir
Nasir

Reputation: 4865

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

I was just wondering why this isnt working:

$('#down-a-bit').mousedown(function(){
    setTimeout( $('html, body').animate({ scrollTop: $(this).offset().top += 1}) ,300); 
});

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

Upvotes: 0

Views: 541

Answers (1)

Maximilian Hils
Maximilian Hils

Reputation: 6770

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

http://jsfiddle.net/pMTsF/

Upvotes: 1

Related Questions