Why jQuery has to receive 2 objects: body & html when scrolling whole page with animation?

早过忘川 提交于 2019-12-23 16:53:39

问题


In all the tutorials I found around the web on animating scrolling of the page with jQuery, I found that most of them are using the following code to do that:

$("html, body").animate(....

I was trying to find out why it's needed to animate 2 objects: html and body, but not luck. I might think it's needed to cover all major browsers… But why really, can someone explain please?


回答1:


chrome/safari uses html to animate, while firefox uses body (might be the other way around, don't remember!)

You could just use $(window).animate.



来源:https://stackoverflow.com/questions/9769630/why-jquery-has-to-receive-2-objects-body-html-when-scrolling-whole-page-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!