Why jQuery has to receive 2 objects: body & html w

2019-07-05 05:18发布

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条回答
beautiful°
2楼-- · 2019-07-05 06:09

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.

查看更多
登录 后发表回答