title: d3 get rect attribute by id
body: <p>I just stuck on a problem when trying to select an attribute of a rect object within a svg.
  This is the rectangle I want to get a value from:</p>
  
  <pre><code>&lt;rect id="2" x="13.761467889908257" y="50" width="49.31192660550459" height="50" fill="rgb(43,0,0)"&gt;&lt;/rect&gt;
  </code></pre>
  
  <p>in order to calculate the x-position of another rectangle I need the x-value.</p>
  
  <p>I tried some different ideas like:</p>
  
  <pre><code>svg.selectAll("rect")
     .select("id",2);               // 1st version
     .select("id","2");             // 2nd version
     .select("#2");                 // found in another d3 tutorial -&gt; not working for me
  </code></pre>
  
  <p>and a lot more. <b>Is there any way to do this?</b></p>
  
  <p>// If you need more of my code just write it in a comment I wasnt sure how much to write in order to NOT write too much</p>