滚动动画无法正常工作;当我单击链接时,我被定向但没有动画
scroll animation not working properly; when i click the link i get directed but with no animation
平滑滚动不起作用?? 当我单击链接滚动到元素/部分时,它直接将我带到它 即使将动画速度更改为 5000 也无法流畅滚动。 我的脚本是正确的,所以我不知道该怎么办
这是我下面的代码; 对于查询,我已经用"#"标签正确标记了我的链接,并为每个元素正确创建了一个 ID
$(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;
}}
});
});
相关文章:
- jquery动画可以通过编程链接吗
- 制作一个不带HTML a标记但在动画播放完毕后指向其他页面的超链接
- 多个链接的Javascript动画
- 无法在第一次单击时禁用链接,并在动画完成后重新启用
- 对链接的 svg 进行动画处理不起作用;内联时工作正常
- 如何正确地链接调用$.show()和$.thoggClass()来触发CSS3动画
- 用这个jQuery动画菜单悬停超链接
- 如何在jquery中链接多组动画
- 如何链接后的CSS动画
- 禁用链接,直到所有动画停止,然后再次启用它们
- j查询使用动画更改图像并等待它触发超链接
- jQuery 淡入淡出图像上的悬停动画会断开链接
- 滚动动画无法正常工作;当我单击链接时,我被定向但没有动画
- 如何从 HTML 5 画布动画链接
- 滚动动画会断开页面上的链接
- 当鼠标悬停在导航链接上时,如何让导航链接进行动画处理
- j查询链接与动画函数的回调
- Chrome动画链接页面加载
- CSS/JS -移除一个li元素的动画链接下划线
- YUI中的动画链接