Dom Adams
Dom Adams

Reputation: 281

$(window).scrollTop() put speed on it

Hi guys i am manipulating the window scrolltop value when some buttons on clicked on my website. Now i want it to scroll down or up to that value on the page slowly not straight away. At the moment the command is working but it just triggers it straight away but what i want it to do is trigger that command and scroll down slowly to the position.

I want it to work exactly how you would do it using .show i.e.

$('#yourID').show(1300);

my code is this:

$(window).scrollTop(500); 

now is there anyway i can tell jquery to go a certain speed with this command?

Thanks Dom

Upvotes: 0

Views: 662

Answers (1)

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

Use animate method:

var scrollSpeed = 5000;
$('html,body').animate({
   scrollTop: 500
},scrollSpeed);

Upvotes: 3

Related Questions