1

I have two SVG elements, my markup:

<svg>
  <circle r="260" fill="#1ABCb6" class="" id="svg_el_obj"></circle>
  <circle r="260" fill="#1ABCb6" class="" id="svg_el_obj"></circle>
</svg>

i need to insert them into <g> tag and in output watch this:

<svg>
  <g>
     <circle r="260" fill="#1ABCb6" class="" id="svg_el_obj"></circle>
  </g>
  <g>
     <circle r="260" fill="#1ABCb6" class="" id="svg_el_obj"></circle>
  </g>
</svg>

I try with jQuery but something is not right:

$('#svg_el_obj').each(function(){
   $(this).html('<g></g>');
}

or

$('#svg_el_obj').each(function(){
   $(this).append('<g></g>');
}

Much thx for help.

Lukas
  • 7,384
  • 20
  • 72
  • 127

1 Answers1

3

You have multiple tags with the same id, id are to be unique. Try using a class instead and wrap

$('.svg_el_obj').wrap('<g>');
Musa
  • 96,336
  • 17
  • 118
  • 137