added text node to SVG group with javascript but does not appear

后端 未结 2 608
一生所求
一生所求 2021-01-23 15:51

This is Javascript that is in the SVG file inside tags.

This SVG shows a timeline of bands in my city. When the mouse clicks on a , the script accesses an XML library a

2条回答
  •  一个人的身影
    2021-01-23 16:22

    In SVG elements must be created in the SVG namespace. This means that createElement won't create an SVG text element, you need createElementNS instead.

    So

    q = document.createElement("text");
    

    should be

    q = document.createElementNS("http://www.w3.org/2000/svg", "text");
    

提交回复
热议问题