0

I would like to add a new path-tag inside an exisiting svg-tag with JavaScript. Is there a way I could achieve this?

In my HTML-File I have defined a svg like this:

<svg viewBox="0 0 1240 1454" x="0px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <!-- HERE I WOULD LIKE TO ADD A NEW PATH-TAG -->
</svg>

I tried with jQuery to append a path-tag (like for example this one) to the svg. But it did not work.

<path d=" M20.5,1441.5 L19,1441.5 Z " fill="#cdd335" fill-opacity="1" id="shape-1"></path>

Is there a way to include new paths to a svg? Do I need another library?

iMax
  • 547
  • 1
  • 8
  • 18
  • @FabianSchultz I tried it with `$('svg').append(data)` it had no impact. should it work? – iMax Nov 19 '16 at 20:29
  • No. jQuery is just appending it as a string, basically. There are answers in the question I liked that make it work without any framework. – Fabian Schultz Nov 19 '16 at 20:49

0 Answers0