x
1
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
2
<ellipse cx="100" cy="100" rx="100" ry="60" id="ellipse"
3
onclick="outputSize();"></ellipse>
4
</svg>
5
6
<script>
7
function outputSize() {
8
const ellipse = document.getElementById("ellipse");
9
10
// "输出 “水平半径:100 垂直半径:60”
11
console.log(
12
`水平半径:${ellipse.rx.baseVal.valueAsString}`,
13
`垂直半径:${ellipse.ry.baseVal.valueAsString}`
14
)
15
}
16
</script>
17