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

后端 未结 2 575
一生所求
一生所求 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 15:59

    Roberts code above works for me on IE11, Thanks Robert!.

    At first I got Object doesn't support property or method 'createElementNS' but found this was due to compatibility mode being enabled on that page, once I removed it things worked fine.

    0 讨论(0)
  • 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");
    
    0 讨论(0)
提交回复
热议问题