Jquery 使用带有标记的图像的锚定标记滚动动画
下面的代码为我的同一页面锚链接设置动画Jquery 使用带有标记的图像的锚定标记滚动动画,jquery,jquery-animate,anchor,Jquery,Jquery Animate,Anchor,下面的代码为我的同一页面锚链接设置动画,但如果我将其与图像组合,则动画不起作用。对于图像,单击将带您到达目标,但不带动画 目的地的格式如下:… 知道我做错了什么吗 $('a').click(function(){ // I tried changing the 'a' to 'img', to no avail... var topoffset = 68; $('html, body').animate({ scrollTop: $( $.attr(this, '
,但如果我将其与图像组合,则动画不起作用
。对于图像,单击将带您到达目标,但不带动画
目的地的格式如下:…
知道我做错了什么吗
$('a').click(function(){ // I tried changing the 'a' to 'img', to no avail...
var topoffset = 68;
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top-topoffset+2
}, 800);
return false;
});
但是如果我将动画与图像结合起来,动画就不起作用。对于图像,单击
将带您到达目的地,但没有动画
是否在stacksnippets处显示以执行动画效果
$('a')。单击(函数(){//我尝试将'a'更改为'img',但没有效果。。。
var-topoffset=68;
$('html,body')。设置动画({
scrollTop:$($.attr(this,'href')).offset().top topoffset+2
}, 800);
返回false;
});代码>
#联系人{
位置:相对位置;
顶部:200px;
}
…
我想出来了。我将脚本移到页面底部,问题自行解决