Reputation: 4113
I was trying out some jQuery examples given in this website. One such example was scrolling back to the top of the page using "animate". Accordingly, I tried this in the console:
$("html, body").animate({scrollTop:0}, "slow");
But I got an error such as this:
VM54:1 Uncaught TypeError: Failed to execute 'animate' on 'Element': duration must be non-negative or auto. at :1:17 (anonymous) @ VM54:1
I even tried giving positive values for scrollTop. But this error occurs. What is the workaround for this issue?
Upvotes: 2
Views: 1650
Reputation: 64727
The site you are running the code on either doesn't include jQuery, or has a version of jQuery that doesn't support that code. $
is not universally jQuery, it can be any variable.
If you, for example, go to jquery.com and run that same code in the console, it will work.
Upvotes: 2