I have an svg container as such
Inside I have a tag to separate the elements by css.
I'd like to create an element dynamically and insert it into the g class tag.
I can use getElementById to get the svg and getElementByClassNAme to get the class "first" but if I try doing getElementByClassName("first").appendChild(element);
I receive this error.
Uncaught TypeError: document.getElementsByClassName(...).appendChild is not a function
How can I insert an element inside the g tag?
Code
<svg viewBox="0 0 100 100" id="svgview">PHP Code
<?php
<g class="first">
PHP Code
<?php
<svg viewBox="0 0 100 100" id="svgview">
<g class="first"></g>
</svg>
I'd like to create an element dynamically and insert it into the g class tag.
I can use getElementById to get the svg and getElementByClassNAme to get the class "first" but if I try doing getElementByClassName("first").appendChild(element);
I receive this error.
Uncaught TypeError: document.getElementsByClassName(...).appendChild is not a function
How can I insert an element inside the g tag?


