jQuery中animate()对Firefox无效的解决办法

    xiaoxiao2021-03-25  107

    在使用 animate()做返回顶部的动画时,会出现对Firefox无效的情况,如:

    $('body').animate({scrollTop:'0'},500);

    它对Chrome,IE,Opera 有效,而另一种情况:

    $('html').animate({scrollTop:'0'},500);

    则只对Firefox有效。

    如果需要对所有浏览器有效,则需要将两者结合起来:

    $('html,body').animate({scrollTop:'0'},500); 这样就可以对所有浏览器有效了。

    转载请注明原文地址: https://ju.6miu.com/read-23308.html

    最新回复(0)