Anything I try to add with javascript doesn't show up. Here is the html.
<svg width="100" height="100" id="test">
<rect width="10" height="10" style="fill:rgb(0,0,255);">
</svg>
The rectangle shows up fine. Here is the javascript:
var b = document.createElement('rect');
b.setAttribute('width', 100);
b.setAttribute('height', 100);
b.setAttribute('style', 'fill:rgb(0,0,255);');
document.getElementById('test').appendChild(b);
Inspect shows this:
<svg width="100" height="100" id="test">
<rect width="10" height="10" style="fill:rgb(0,0,255);">
<rect width="100" height="100" style="fill:rgb(0,0,255);">
</svg>
But b
doesn't show up. Does the svg have to be updated or something?
Note: I would like to avoid external libraries like jQuery and keep this a simple as possible.