JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <head>
<script src="http://d3js.org/d3.v2.js"></script>
    </head>
    <body>
        <div id="container"></div>
    </body>
</html>

JavaScript

function go() {
var cont = d3.select("#container").html("")
    .append("svg")
    .attr("xmlns","http://www.w3.org/2000/svg")
    .attr("width","200")
    .attr("height","200");

    console.log(cont);
                      
cont.append("foreignObject").attr("x","40").attr("y","40")
    .attr("width","100").attr("height","100")
    .append("div")
    .text("test");
}
    go();