我写了一个简单的代码,在我点击按钮时将一行添加到我的 SVG 页面中。
这是 HTML。
这是 HTML。
<body>
<svg width="500" height="400">
</svg>
<button id="btn1">Append text</button>
</body>
以及脚本
$(document).ready(function(){
$("#btn1").click(function(){
$("svg").append(' <line x1="10" y1="10" x2="40" y2="40" style="stroke: black">' );
console.log("done!");
});
});
而且 jsfiddle https://jsfiddle.net/dch7xyez/1/
这行代码被添加了,但是不可见。有人能解释一下为什么吗?