title: Getting d3.js data from html
body: <p>I'm new to d3.js and trying to understand how to retrieve elements that are already on an html page. </p>
  
  <p>If I try something like the following, 'd' is undefined when I look in the console log. I can access some of the td information via the 'this' keyword, but looking at the d3 API <a href="https://github.com/mbostock/d3/wiki/Selections#wiki-style" rel="nofollow">https://github.com/mbostock/d3/wiki/Selections#wiki-style</a>, it says if style takes a value as a function, it passes the current 'datum' and index.</p>
  
  <p>I can get the index fine, but datum is always undefined. Is there something obvious I'm missing to retrieve the values, or have the wrong way around ?</p>
  
  <pre><code>&lt;table class="results"&gt;
  &lt;tr&gt;&lt;td&gt;13/1/0014&lt;/td&gt;&lt;td&gt;81&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;12/1/0014&lt;/td&gt;&lt;td&gt;690&lt;/td&gt;&lt;td&gt;47&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;5/1/0014&lt;/td&gt;&lt;td&gt;450&lt;/td&gt;&lt;td&gt;26&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  
  d3.selectAll(".results td:nth-child(4n+2)")
    .style("background-color", function(d) { 
           console.log( d );
  
           //change style depending on d, but d is always undefined
           //I can access the elements via this, but not d ? 
  
  });
  </code></pre>
  
  <p>jsfiddle <a href="http://jsfiddle.net/a5WkH/2/" rel="nofollow">http://jsfiddle.net/a5WkH/2/</a></p>