JSFiddle - React, Tailwind, and code Playground

by Alexandr_T

HTML

<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.querySelector("#div1 .rect1").setAttribute("fill","red");
    document.querySelector("#div2 .rect1").setAttribute("fill","green");