0

I am trying to understand D3 but even when following a tutorial identically it does not work..

here is the code which I told would have gave me an array of td but which instead does not give anything:

<body>

<!-- load the d3.js library -->
<script src="https://d3js.org/d3.v3.min.js"></script>
<script>

var td = d3.selectAll("tbody tr").selectAll("td");

td.style("color", function(d, i) { return i ? null : "red"; });

var len = td.lenght

console.log(td)
console.log(len)

</script>

<table>
  <thead>
    <tr><td>  A</td><td>  B</td><td>  C</td><td>  D</td></tr>
  </thead>
  <tbody>
    <tr><td>  0</td><td>  1</td><td>  2</td><td>  3</td></tr>
    <tr><td>  4</td><td>  5</td><td>  6</td><td>  7</td></tr>
    <tr><td>  8</td><td>  9</td><td> 10</td><td> 11</td></tr>
    <tr><td> 12</td><td> 13</td><td> 14</td><td> 15</td></tr>
  </tbody>
</table>


</body>

neither makes anything red.. not a clue why

user3755529
  • 756
  • 6
  • 18
  • mine is inside `` and even if I put ` – user3755529 Dec 27 '17 at 23:15
  • 1
    Please, also read the [comment](https://stackoverflow.com/questions/13142591/d3-select-method-not-working/13144384#comment61440441_13144384) on the accepted answer. The script needs to be put **after** the elements it tries to select, i.e. put it at the end of the body. – altocumulus Dec 27 '17 at 23:21
  • great that sorted it, still this question could be useful to whoever follows that tutorial, it is really not well explained – user3755529 Dec 27 '17 at 23:23

0 Answers0