试图弄清楚为什么chrome会抛出错误
"未捕获的TypeError:无法读取未定义的属性'left'"
虽然#explorenav效果很好,但#experiencenav似乎没有起作用.我错过了什么吗?
JS代码:
$('.nav li#explorenav a').click(function(){
$('body').animate({scrollLeft: $("#explore").offset().left-15}, 1000, function(){
$(this).parent().addClass('active');
});
return false;
});
$('.nav li#experiencenav a').click(function(){
$('body').animate({scrollLeft: $("#experience").offset().left-15}, 1200, function(){
$(this).parent().addClass('active');
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<div id="explore">
<div class="Features">
<div class="Feature1" title="The Active Park Assist feature can find parking spaces for you and help manoeuvre your car into them, as if by magic.">
</div>
<div class="Feature2" title="The luxurious and athletic Interior has sports front seats with red stitching and belts, making …Run Code Online (Sandbox Code Playgroud)