JSFiddle - React, Tailwind, and code Playground

HTML

<button id="myBtn">Click</button>

JavaScript

var svgNS = "http://www.w3.org/2000/svg";
var myBtn = document.getElementById("myBtn");
myBtn.addEventListener("click", createSVGCircle);

function createSVG() {
    var svg = document.createElementNS(svgNS, 'svg');
    svg.setAttribute('id', 'mySVG');
    document.body.appendChild(svg);
}

function createSVGCircle() {
    createSVG();
    var el = document.getElementById("mySVG");
    var circle = document.createElementNS(svgNS, 'circle');
    circle.setAttribute('cy', 50);
    circle.setAttribute('cx', 50);
    circle.setAttribute('r', 20);
    circle.setAttribute('fill', 'blue');
    el.appendChild(circle);
}


//createSVGCircle();