Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between scroll and scrollTop in javascript/jQuery

What is the difference between:

window.scroll(0,200);

AND

$(window).scrollTop(200);

Apart from the fact that one of them is using jQuery and the other is not, what is the difference? Does one animate the scroll and the other doesn't? Will one work faster than the other?

like image 405
Nosrettap Avatar asked Nov 01 '22 21:11

Nosrettap


1 Answers

.scrollTo() or .scroll() is applicable on window object while .scrollTop() works with any DOM element

like image 154
Jyoti Duhan Avatar answered Nov 09 '22 07:11

Jyoti Duhan