0
我想计算屏幕下滚多远。我通过计算顶部窗口的像素来做到这一点。这是我的代码:变量不适用于动画滚动
$('#nav_ibutton_start').click(function(){
header = $('#header_wrapper').offset().top;
element = $('#ibutton_products').offset().top;
pos = header-element;
$("html, body").animate({ scrollTop: pos }, "slow");
});
我已提醒'pos'变量,它是正确的数字。我已经测试它没有变量,例如:
$("html, body").animate({ scrollTop: 500 }, "slow");
它也可以正常工作。为什么当我使用'pos'变量时它不起作用?
哦,你是对的!不知道我是如何管理的。还意识到我真的想要header = $('#header_wrapper')。height(); – user2909486