JavaScript createElementNS and SVG

前端 未结 4 1660
轻奢々
轻奢々 2020-11-28 09:56

I want to create inline SVG graphics using Javascript.

However, it seems like createElementNS function applies some normalization and transforms all tags

4条回答
  •  甜味超标
    2020-11-28 10:27

    I have just resolved a similar problem. document.createElement (and I assume document.createElementNS), when called from a HTML page creates a HTML node (where case doesnt matter), not an xml node.

    The following works in Chrome:

    doc = document.implementation.createDocument(null, null, null); doc.createElementNS("http://www.w3.org/2000/svg","textPath");

    you will get your mixed case node.

提交回复
热议问题