How to manipulate SVG element style with javascript?
<p>I've created an inline svg with a few rectangle elements and set the same color to all of them in css. I gave an id to each of them and now want to manipulate them with plain javascript in order to change the color of each rectangle. My javascript code does validate correct and I can see in the console that the rectangles are selected, but their color didn't change. Any suggestion on what I'm doing wrong and how I can fix it? Thanks in advance!
Example of my html code: </p>

<pre><code>&lt;rect id="rect1" width="40" height="230" x="20" y="170" rx="10"/&gt;
&lt;rect id="rect2" width="40" height="300" x="60" y="100" rx="10"/&gt;
</code></pre>

<p>My javascript code:</p>

<pre><code>var rect1 = document.getElementById("rect1");
console.log(rect1);
rect1.setAttribute("style", "color: red");
</code></pre>