Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 1.91 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Getting Uncaught TypeError: Cannot read property 'left' of null in js
  2. navigation arrow starts
  3. var $el, leftPos, newWidth,
  4.     $mainNav = $("#nav");
  5.  
  6. $mainNav.append("<li id='magic-line'></li>");
  7. var $magicLine = $("#magic-line");
  8.  
  9. $magicLine
  10.     .width($(".current_page_item").width())
  11.     .css("left", $(".current_page_item a").position().left)
  12.     .data("origLeft", $magicLine.position().left)
  13.     .data("origWidth", $magicLine.width());
  14.  
  15. //scroll arrow
  16.  
  17. function update_location(){
  18.     $el = $('#nav').children('li.current');
  19.     leftPos = $el.position().left;
  20.     newWidth = $el.width();
  21.     $('#nav li:nth-child(4) a').addClass('button-style');
  22.     if(window.top.scrollY == 0)
  23.     {
  24.         setTimeout(function(){
  25.         $magicLine.stop().animate({
  26.             left: 8,
  27.             width: 355
  28.         });},1000);
  29.         $('#nav li:nth-child(4) a').removeClass('button-style');
  30.  
  31.     }
  32.     else
  33.     {
  34.         setTimeout(function(){
  35.         $magicLine.stop().animate({
  36.             left: leftPos,
  37.             width: newWidth
  38.         });},1000);
  39.     }
  40. }
  41.  
  42. $('#magic-line').css('left', '-15px', 'width','411px');
  43. $(window).scroll(function(){
  44.     update_location();
  45. });
  46.  
  47.     <div class="navbar-fixed-top navbar" >
  48.     <div class="navbar-inner">
  49.         <div class="container">
  50.             <ul class="nav nav-pills pull-right" id="nav">
  51.                 <li class="current_page_item" style="width: 355px;"><a href="#home" class="logo" style="display:block; width: 355px;"><img src="images/logo.jpg" class="current_page_item" width="355" alt="" /></a></li>
  52.                 <li><a href="#vision">VISION</a></li>
  53.                 <li><a href="#services">SCHOOLS</a></li>
  54.                 <li><a href="#apply">REQUEST AN EVALUATION</a></li>
  55.                 <li><a href="#how-it-works">HOW IT WORKS</a></li>
  56.                 <li><a href="#contact-us">CONTACT US</a></li>
  57.             </ul>
  58.         </div>
  59.     </div>
  60. </div>
  61.        
  62. $el = $('#nav').children('li.current');