我一直在尝试使用JavaScript在HTML中进行SVG操作的“Hello World”。我编写了下面的代码,虽然它生成了正确的HTML,但是在浏览器中没有看到任何输出,也没有看到任何错误。
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var svg1 = document.createElement("svg");
svg1.setAttribute("height",200);
svg1.setAttribute("width",500);
document.body.appendChild(svg1);
var circles = document.createElement("circle");
circles.setAttribute("cx",20);
circles.setAttribute("cy",20);
circles.setAttribute("r",20);
svg1.appendChild(circles);
</script>
</body>
</html>
我哪里做错了?谢谢提前。