Jquery scrollTop()未滚动到IE windows 8 phone上的正确位置
它在任何地方都可以正常工作,虽然浏览器返回正确的高度,但它会滚动到错误的位置(每次都不同)。这只发生在IE W8手机上,下面是代码:Jquery scrollTop()未滚动到IE windows 8 phone上的正确位置,jquery,internet-explorer,mobile,windows-mobile,Jquery,Internet Explorer,Mobile,Windows Mobile,它在任何地方都可以正常工作,虽然浏览器返回正确的高度,但它会滚动到错误的位置(每次都不同)。这只发生在IE W8手机上,下面是代码: $("#navigation-wrapper a").click(function(e){ $headerHeight = $("#header").height(); var $anchor = $(this); $('html, body').stop().animate({scrollTop: $($anchor.attr('href
$("#navigation-wrapper a").click(function(e){
$headerHeight = $("#header").height();
var $anchor = $(this);
$('html, body').stop().animate({scrollTop: $($anchor.attr('href')).offset().top - $headerHeight});
e.preventDefault(); });
有什么想法吗?虽然这很混乱,但出于某种原因,它起了作用。为了滚动到正确的位置,我不得不调用animate两次
$('html, body').stop()
.animate({scrollTop: $($anchor.attr('href')).offset().top - $headerSize},function(){
$('html, body').stop()
.animate({scrollTop: $($anchor.attr('href')).offset().top - $headerSize});
});
我也注意到了这一点。对我来说,它也在反弹,而它本不应该反弹,所以我假设它是一个jQuery bug。