title: javascript get child by id
body: <pre><code>&lt;div onclick="test(this)"&gt;
      Test
      &lt;div id="child"&gt;child&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to change the style of the child div when the parent div is clicked.  How do I reference it?  I would like to be able to reference it by ID as the the html in the parent div could change and the child won't be the first child etc.</p>
  
  <pre><code>function test(el){
    el.childNode["child"].style.display = "none";
  }
  </code></pre>
  
  <p>Something like that, where I can reference the child node by id and set the style of it.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:  Point taken with IDs needing to be unique.  So let me revise my question a little.  I would hate to have to create unique IDs for every element that gets added to the page. The parent div is added dynamically. (sort of like a page notes system).  And then there is this child div.  I would like to be able to do something like this: el.getElementsByName("options").item(0).style.display = "block";</p>
  
  <p>If I replace el with document, it works fine, but it doesn't to every "options" child div on the page.  Whereas, I want to be able to click the parent div, and have the child div do something (like go away for example).</p>
  
  <p>If I have to dynamically create a million (exaggerated) div IDs, I will, but I would rather not.  Any ideas?</p>