Javascript 滚动动画工作不正常;当我点击链接时,我得到了指示,但没有动画
平滑滚动不起作用??当我单击链接滚动到某个元素/部分时,它会直接将我带到该元素/部分,即使将动画速度更改为5000,也不会平滑滚动。我的脚本是正确的,所以我不知道该怎么做 这是我下面的代码;对于查询,我已经用“#”标记正确地标记了我的链接,并为我的每个元素正确地创建了一个IDJavascript 滚动动画工作不正常;当我点击链接时,我得到了指示,但没有动画,javascript,jquery,html,animation,jquery-animate,Javascript,Jquery,Html,Animation,Jquery Animate,平滑滚动不起作用??当我单击链接滚动到某个元素/部分时,它会直接将我带到该元素/部分,即使将动画速度更改为5000,也不会平滑滚动。我的脚本是正确的,所以我不知道该怎么做 这是我下面的代码;对于查询,我已经用“#”标记正确地标记了我的链接,并为我的每个元素正确地创建了一个ID $(function() { $('a[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^\
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 5000);
return false;
}
}
});
});
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}}
});
});