2013-03-21 48 views
7

Cố gắng tìm hiểu xem tại sao chrome được ném ra lỗikhông thể đọc thuộc tính 'left' không xác định

"Uncaught TypeError: Cannot read property 'left' of undefined"

mặc dù #explorenav hoạt động tuyệt vời nhưng #experiencenav dường như không có tác dụng. tui bỏ lỡ điều gì vậy?

JS Mã sản phẩm:

$('.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; 
}); 

HTML Mã sản phẩm:

<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."> 
      &nbsp; 
     </div> 
     <div class="Feature2" title="The luxurious and athletic Interior has sports front seats with red stitching and belts, making you wish the journey never ended"> 
      &nbsp; 
     </div> 
     <div class="Feature3" title="With Collision Prevention Assist and Attention Assist you can rest assured that you’ll get to wherever you’re going, safely."> 
      &nbsp; 
     </div> 
    </div> 
</div> 

<div id="experience"> 
    <div class="Video"> 
     <iframe id="Youtube" width="650" height="366" src="http://www.youtube.com/embed/XS6S8qSMvBE?wmode=opaque" frameborder="0" wmode="transparent" allowfullscreen ALLOWTRANSPARENCY="true"></iframe> 

     <button class="prev">&nbsp;</button> 
     <button class="next">&nbsp;</button> 
     <div class="VideoControls"> 
      <ul class="Vid"> 
       <li id="01" class="Video1" onClick="_gaq.push(['_trackEvent', 'Pulse', 'onClick', 'ENGLISH']);"> 
        &nbsp; 
       </li> 
       <li id="02" class="Video2" onClick="_gaq.push(['_trackEvent', 'Performance', 'onClick', 'ENGLISH']);"> 
        &nbsp; 
       </li> 
       <li id="03" class="Video3" onClick="_gaq.push(['_trackEvent', 'Parking Assist', 'onClick', 'ENGLISH']);"> 
        &nbsp; 
       </li> 
       <li id="04" class="Video4" onClick="_gaq.push(['_trackEvent', 'Flow', 'onClick', 'ENGLISH']);"> 
        &nbsp; 
       </li> 
       <li id="05" class="Video5" onClick="_gaq.push(['_trackEvent', 'Spike', 'onClick', 'ENGLISH']);"> 
        &nbsp; 
       </li> 
       <li id="06" class="Video6" onClick="_gaq.push(['_trackEvent', 'Product film', 'onClick', 'ENGLISH']);"> 
        &nbsp; 
       </li> 
      </ul> 
     </div> 
    </div> 
</div> 
+2

Bạn có thể đăng mã html của mình không? Có thể đó là lỗi đánh máy trong html của bạn và nó không thể tìm thấy $ ("# kinh nghiệm") – freshbm

+1

Chúng tôi không thể giúp các bạn khi bạn tham khảo mã mà chúng tôi không biết ... –

+0

tại sao không phải là jquery này? @ JohannesKlauß – AbdulWahhab

Trả lời

2

Trong kịch bản của bạn trên trang web của bạn có mã này:

$('.nav li#experiencenav a').click(function(){ 
    $('body').animate({scrollLeft: $("#experience .EmptyPage").offset().left-20}, 1200, function(){ 
     $(this).parent().addClass('active'); 
     $('li#homenav, li#discovernav, li#explorenav, li#downloadnav').removeClass('active'); 
    }); 
     return false; 
    }); 

và nó không thể tìm thấy yếu tố $("#experience .EmptyPage"). Nhưng bạn đã div bên trong div của bạn #explore có div này:

<div class="EmptyPage"> 
&nbsp; 
</div> 

Thats lý do tại sao mã của bạn đang làm việc cho khám phá liên kết, nhưng không phải cho các liên kết khác.

+0

yea tôi chỉ thấy rằng bây giờ, lol đây là tất cả áp lực công việc: P quản lý của tôi chỉ cần 3 ngày để hoàn thành toàn bộ trang web -_-. anw cảm ơn rất nhiều – AbdulWahhab

Các vấn đề liên quan