title: D3 get attributes from element
body: <p>I am trying some basic d3 and i have been trying to get the attributes of each of the <code>rect</code> using d3 but I am not able to get anything.</p>
  <p><a href="https://i.stack.imgur.com/fHfpS.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fHfpS.jpg" alt="Console Screen" /></a></p>
  <p>When i try <code>d3.selectAll(&quot;rect&quot;)</code>, I get</p>
  <p><a href="https://i.stack.imgur.com/KW9nU.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/KW9nU.jpg" alt="result" /></a></p>
  <p>How do can i access attributes of <code>rect</code> by using something like <code>d3.selectAll(&quot;rect&quot;).select(&quot;part1&quot;).attr(...)</code> or something similar? I want to access different attributes of all <code>rect</code>.</p>