<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SVG DOM绘制椭圆</title>
<style>
#myellipse{
width: 200px;
height: 200px;
border: 1px solid red;
}
</style>
<script>
function createEllipse(){
var root=document.getElementByIdx_x("myellipse");
var SVG="http://www.w3.org/2000/svg";
//创建svg元素
var svg=document_createElement_xNS(SVG,"svg");
svg.setAttribute("width","200");
svg.setAttribute("height","200");
//创建我们的椭圆的元素
var ellipse=document_createElement_xNS(SVG,"ellipse");
ellipse.setAttribute("cx","100");
ellipse.setAttribute("cy","100");
ellipse.setAttribute("rx","50");
ellipse.setAttribute("ry","100");
svg.a(ellipse);
root.a(svg);
}
</script>
</head>
<body οnlοad="createEllipse()">
<h3>svgdom绘制椭圆</h3>
<div id="myellipse"></div>
</body>
</html>