title: childNodes.length 0 in Chrome / Correct In IE & FF
body: <p>I have a div with children that I need to crawl looking for specific links. The HTML looks like so:</p>
  
  <pre><code>&lt;div id="ctl00_LeftNav"&gt;
      &lt;h3&gt;
          &lt;a href="../App_Templates/#" rel="0"&gt;Menu 1&lt;/a&gt;&lt;/h3&gt;
      &lt;div&gt;
          &lt;p&gt;
              &lt;span&gt;
                  &lt;div style="padding-left: 0px; font-weight: bold;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(1);"&gt;Opt 1&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="padding-left: 10px;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(56);"&gt;Opt 1a&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="padding-left: 0px; font-weight: bold;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(2);"&gt;Opt 2&lt;/a&gt;&lt;/div&gt;
              &lt;/span&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;h3&gt;
          &lt;a href="../App_Templates/#" rel="1"&gt;Menu 2&lt;/a&gt;&lt;/h3&gt;
      &lt;div&gt;
          &lt;p&gt;
              &lt;span&gt;
                  &lt;div style="padding-left: 0px; font-weight: bold;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(33);"&gt;Opt 1&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="padding-left: 0px; font-weight: bold;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(34);"&gt;Opt 2&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="padding-left: 10px;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(42);"&gt;Opt 2a&lt;/a&gt;&lt;/div&gt;
              &lt;/span&gt;
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;h3&gt;
          &lt;a href="../App_Templates/#" rel="2"&gt;Menu 3&lt;/a&gt;&lt;/h3&gt;
      &lt;div&gt;
          &lt;p&gt;
              &lt;span&gt;
                  &lt;div style="padding-left: 0px; font-weight: bold;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(58);"&gt;Opt 1&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="padding-left: 0px; font-weight: bold;"&gt;
                      &lt;a href="javascript:OnLeftMenuSelection(59);"&gt;Opt 2&lt;/a&gt;&lt;/div&gt;
              &lt;/span&gt;
          &lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The Javascript that I have works fine in IE / Firefox, but fails in Chrome:</p>
  
  <pre><code>        function OnPageLoadCategorySelect(Category) {            
          var Root = $j('#ctl00_LeftNav').children();
          var Tab = 0;
          for (var i = 1; i &lt; Root.length; i += 2) {
              var Menu = Root[i].firstChild.firstChild.childNodes;                
              var MenuLength = Menu.length;
              for (var j = 0; j &lt; Menu.length; j++) {
                  var Link = Menu[j].innerHTML;
                  var Start = Link.indexOf('(');
                  var End = Link.indexOf(')');
                  var Res = Link.slice(Start + 1, End);
                  if (Res == Category) {
                      SelectedTabIndex = Tab;                        
                      OnLeftMenuSelection(Category);
                      $j('#ShopTabs').show();
                      $j('#ctl00_LeftNav').accordion('activate', Tab);                      
                      return;
                  }
              }                
              Tab++;                
          }
      }
  </code></pre>
  
  <p>In Chrome the 2nd for loop never executes because Menu.length is zero. What would be the best way to get these internal divs? </p>
  
  <p><em>Solution</em></p>
  
  <pre><code>function OnPageLoadCategorySelect(Category) {
  $j("#ctl00_LeftNav &gt; div").each(function(Tab, el) {
              $j('a', this).each(function() {
                  var id = $j(this).attr('href').replace('javascript:OnLeftMenuSelection(', '').replace(');', '');
                  if (id == Category) {
                      SelectedTabIndex = Tab;
                      OnLeftMenuSelection(Category);
                      $j('#ShopTabs').show();
                      $j('#ctl00_LeftNav').accordion('activate', Tab);
                      return false; // exit the loop
                  }
              })
          });
   }
  </code></pre>