jQuery中animate()的方法以及$("body").animate({"scrollTop":top})不被Firefox支持问题的解决

时间:2023-03-09 04:12:08
jQuery中animate()的方法以及$("body").animate({"scrollTop":top})不被Firefox支持问题的解决

转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/50846678

本文出自【我是干勾鱼的博客

jQuery中animate()的方法能够去w3school查看。这里主要说一下:

$("body").animate({"scrollTop":top})

不被Firefox支持问题的解决。

事实上是使用body的:

$("body").animate({"scrollTop":top})

仅仅被chrome支持,而不被Firefox支持。

而使用html的:

$("html").animate({"scrollTop":top})

仅仅被Firefox支持。而不被chrome支持。

假设想让这段jschromeFirefox都支持的话,应该这样:

$("html,body").animate({"scrollTop":top})

看到了吗。就是将htmlbody这两者都加上就能够了。