title: JavaScript get child element
body: <p>Why this does not work in firefox i try to select the category and then make subcategory visible.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function show_sub(cat) {
        var cat = document.getElementById("cat");
        var sub = cat.getElementsByName("sub");
        sub[0].style.display='inline'; 
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>-</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li id="cat" onclick="show_sub(this)"&gt;
          Top 1
          &lt;ul style="display:none" name="sub"&gt;
              &lt;li&gt;Sub 1&lt;/li&gt;
              &lt;li&gt;Sub 2&lt;/li&gt;
              &lt;li&gt;Sub 3&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Top 2&lt;/li&gt;
      &lt;li&gt;Top 3&lt;/li&gt;
      &lt;li&gt;Top 4&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>EDIT Answer is: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     function show_sub(cat) {
        cat.getElementsByTagName("ul")[0].style.display = (cat.getElementsByTagName("ul")[0].style.display == "none") ? "inline" : "none";
     }
  &lt;/script&gt;
  </code></pre>