title: d3.select("#element") not working when code above the html element
body: <p>This works:</p>
  
  <pre><code>&lt;div id="chart"&gt;&lt;/div&gt;
  &lt;script&gt;var svg = d3.select("#chart").append("svg:svg");&lt;/script&gt;
  </code></pre>
  
  <p>This doesn't:</p>
  
  <pre><code>&lt;script&gt;var svg = d3.select("#chart").append("svg:svg");&lt;/script&gt;
  &lt;div id="chart"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I tried wrapping the code in a jquery document.ready(), grabbing the element with jquery, and passing it into d3.select, but that didn't work either. <strong>Edit</strong> Once I got the jquery document.ready() syntax right, it worked.</p>
  
  <p>Any way I can include the javascript at the top of the page and still select an element below? Thanks.</p>