Javascript .为ScrollTop制作动画,但效果不佳

Javascript .为ScrollTop制作动画,但效果不佳,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我有JQuery代码来制作ScrollTop的动画 浏览器滚动到所需位置,但不平滑 function scrollto_aboutUsSection(){ // alert("about us scroll called"); $("html,body").animate({scrollTop: $("#aboutUs_section").offset().top }, 0.001); } HTML代码如下所示 <div id="container"> <?

我有JQuery代码来制作ScrollTop的动画

浏览器滚动到所需位置,但不平滑

function scrollto_aboutUsSection(){
// alert("about us scroll called");
$("html,body").animate({scrollTop: $("#aboutUs_section").offset().top }, 0.001);
}
HTML代码如下所示

<div id="container">

        <?php include("Includes/header&nav.html"); ?>

        <div id="content">

            <?php include("Includes/information_section.html"); ?>

            <section id = "aboutUs_section" class="Section">
                <h2 class="textShadow big_h2_font"> About Us </h2>
                <p class="textShadow">  In 1987, Our founders laid the foundation of jewellery store in Gakhar Plaza, Saddar, Rawalpindi. Since that time we are in service in presentation of artistic jewels by the hands of talented craft persons and skilled artists. We still try our best to come up with ideas that matches with yours most, keeping the eye on craftmanships side by side. We deal in 21K, Embedded and non Embedded Jewels generally.
                </br></br>If you are looking for 22K, we take orders as well.
                </br></br>Visit our Gallery and have a look at our Jewels Range.  </p>
            </section> 
</div> </div>

关于我们
在1987,我们的创始人为珠宝店在拉瓦尔品第Saddar的加哈尔广场奠定了基础。从那时起,我们一直致力于由有才华的工艺人员和熟练的艺术家来展示艺术珠宝。我们仍然尽最大努力想出最符合您的想法,同时密切关注手工艺。我们一般经营21K嵌入式和非嵌入式珠宝。


如果您要购买22K,我们也接受订单。

参观我们的画廊,看看我们的珠宝系列

其他函数调用这个JQuery函数

我已将
包含在body标记内的html代码中。这个JQuery函数也调用页面加载。所以这不是它顺利跳过动画的原因


在PHP之前,它工作得很好。

您使用的速度非常慢。使用以下命令:

$("html,body").animate({scrollTop: $("#aboutUs_section").offset().top }, 1000);
注意最后一个值
1000
,而不是原来的
0.001


这是以毫秒为单位的速度。所以1000是1秒。

给它一些时间来制作动画
0.001
意味着几乎为零。。。例如,尝试
500
,这是半秒。是的,你是对的!我理解并解决了这个问题非常感谢你。它帮助了我。