Is it possible to append a div inside an SVG element? Is it possible to append a div inside an SVG element? jquery jquery

Is it possible to append a div inside an SVG element?


You can't append HTML to SVG (technically you can with foreignObject, but it's a rabbit hole). Furthermore, visible elements in SVG can't be nested, so elements such as circle, rect, path and such can't have children elements.


I would also consider using <g> element as it serves similar purpose as <div> by grouping objects. More about it here.


You are trying to append "rect" as well as "div" in the same line. Porbably that is where you are failingCheck out these tutotials for D3... Its an amazing library based on SVGhttp://alignedleft.com/tutorials/d3/drawing-svgs/