title: d3 - select/unselect node onclick
body: <p>In the following <a href="http://jsfiddle.net/Rwd4q/" rel="nofollow">jsfiddle</a> the select logic works but the unselect logic does not.
  I have no idea why.</p>
  
  <pre><code>var selected;
  function click(){
  
    // If nothing is selected then select the clicked node.
    if(!selected){
      selected = d3.select(this);
      selected.style('stroke', 'black');
    }
  
    // If the clicked node is already selected then unselect it.
    else if(selected == d3.select(this)){
      selected.style('stroke', 'white');
      selected = undefined;
    }
  }
  </code></pre>