JSFiddle - React, Tailwind, and code Playground
by Alexandr_T
HTML
<title></title>
<body>
<div id="div1">
<svg xmlns="http://www.w3.org/2000/svg" width="50px" height="50px">
<rect class="rect1" width="50px" height="50px"/>
</svg>
</div>
<div id="div2">
<svg xmlns="http://www.w3.org/2000/svg" width="50px" height="50px">
<rect class="rect1" width="50px" height="50px"/>
</svg>
</div>
</body>
JavaScript
document.getElementById("div1").getElementsByClassName("rect1")[0].setAttribute("fill","dodgerblue");
document.getElementById("div2").getElementsByClassName("rect1")[0].setAttribute("fill","yellowgreen");