I need to create html using javascript and I want to add an anchor with a polygon to my svg viewBox
var createHtml = () => {
const svg = document.querySelector('svg');
var svgNS = svg.namespaceURI;
for (let index = 0; index < 10; index++) {
var link = document.createElement("a");
var poly = document.createElement("polygon");
poly.setAttribute("opacity", 1);
poly.setAttribute("points", [0, 0, 0, 500, 500, 500, 500, 0]);
link.appendChild(poly);
svg.appendChild(link);
}
}
createHtml();
<html>
<head>
</head>
<body>
<figure id="imagemap">
<svg id="box" viewBox="0 0 1700 1020">
</svg>
</figure>
<script src="main.js"></script>
</body>
</html>
with this setup I can see the html in the examine chrome tool, but it doesn't show up in my viewBox. Only if I for example change the opacity with "change as html" it does show up.
Why would it only show up after changing something WITH "change as html", because double clicking results in no change? http://jsfiddle.net/n4poxL0a/2/