[英]jQuery scrollTop doesn't animate in FF or IE but working fine in chrome
Already tried with $(window) or $(document) they're not working either. 已经用$(window)或$(document)尝试了,它们都不起作用。
$('a[href^="#"').on('click', function () {
var id = $(this).attr("href");
var target = $(id).offset().top;
//Animation
$('body,html').animate({ scrollTop: target }, 500);
return false;
});
You're missing the closing ]
in your selector so it is throwing an error and not hooking up the click handler. 您在选择器中缺少[
]
结束符,因此它引发了错误,并且没有关联点击处理程序。
$('a[href^="#"]').on('click', function (event) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.