【发布时间】:2017-06-21 13:28:10
【问题描述】:
我正在尝试让这个脚本工作:
function scrollToAnchor(aid)
{
if($(".error").length > 0)
{
var firstErrorElement = $(".error").first();
$('html,body').animate({scrollTop:firstErrorElement.offset().top},'slow');
}
var aTag = $("a[name='"+ aid +"']");
$('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
请看看我要做什么here。
【问题讨论】:
-
抱歉,这里有问题吗?
-
有谁知道这段代码的问题出在哪里?
-
函数 scrollToAnchor(aid){ if($(".error").length > 0) { var firstErrorElement = $(".error").first(); $('html,body').animate({scrollTop:firstErrorElement.offset().top},'slow'); } var aTag = $("a[name='"+ 辅助 +"']"); $('html,body').animate({scrollTop: aTag.offset().top},'slow'); }