动态修改svg文件的内容

我来纠错
//SVG文件
<?xml version="1.0"standalone="no"?>
<!DOCTYPE svg PUBLIC"-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<text id="txt"x="65"y="70"style="font-size:12px;"fill="red">Hello</text>
</svg>


//text标签必须有初值 方法一:
txt = svgDocument.getElementById("txt");
txt.firstChild.nodeValue="Hello World !";

//方法二:
var txt=svgDocument.getElementById("txt");
var newText = svgDocument.createTextNode("Hello World !");
txt.replaceChild(newText,txt.firstChild);
发送
热门关键词:
命令
知识类型:
标题描述:
详细解答:

提交审核您编辑的知识会经过 前端大牛 人工审核。