score:7

Accepted answer

in d3.js v4, attr and style only accept one attribute/value pair as parameters:

d3.selectall('.myrectangle').style('fill', 'rgb(255,100,100)')

in order to pass an object with multiple values, you have to use attrs and styles instead of attr and style and also include https://d3js.org/d3-selection-multi.v0.4.min.js file in your web page.

alternatively, you may chain several attr, one for each attribute. idem for style.

reference: d3-selection-multi

score:2

the other post is correct that you can only set one attribute or style to one thing at a time. but "style" is an attribute, which accepts a single string!

d3.selectall('.myrectangle').attr("style", "fill:rgb(255,100,100);stroke:#000;stroke-width:0.3;")