I can't complete this

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

<style>
.bar {
  width: 25px;
  height: 100px;
  display: inline-block;
  background-color: blue;
}
</style>
<body>
<script>
  const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

  d3.select("body").selectAll("div")
    .data(dataset)
    .enter()
    .append("div")
    // Add your code below this line
   .attr("bar", "div");

    // Add your code above this line
</script>
</body>
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Add Classes with D3

Link to the challenge:

Your .attr() is wrong. The previous methods already have div selected :wink:
.attr() can change any attribute, so you need to tell it WHICH “attribute” it should change, as well as with what “value” it should give it.

i want change width of bar class from 25px to 14px then i rewrite code like this
.attr(“width”,“14px”);
I just have learned for 2 hour so I can understand hihi!!!

That won’t work because there is no attribute “width” for div.
Most styling is done via CSS and that is written in the “style” attribute. In this case as inline-CSS.

so thank you so much, i am pleased because you reply me

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.