$(window).scrollTop() vs. $(document).scrollTop()

2013年2月19日 星期二

筆記一下

They are both going to have the same effect.

Both scroll to the top of the object, an html document is considered the "document" thus scrolling to the top of the html page. A "window" object is created with each frame, thus your main window is one frame, if you had an "iframe" that would create another window object. So your just scrolling to the top of the window object, creating the same effect.

It seems that the window object is buggy when it comes to this. It apprently does not work in IE8 and Opera, so it is best to use $("html").scrollTop().

所以最好是用$("html").scrollTop().可支援多瀏覽器

 

 

 

 

資料來源:http://stackoverflow.com/questions/5371139/window-scrolltop-vs-document-scrolltop

0 意見: