小编Len*_*Len的帖子

如何通过按javascript/svg中的按钮将形状的半径设置为更大或更小

嗨,我有以下代码,我希望能够通过按一个按钮改变圆的半径我不知道在风格后使用什么.在document.getElementById("circle1")中.style.r ="10"; 部分代码

<html>
    <head>
    <script>
    function circle() {
        document.getElementById("circle").style.r="50";
}

    function circle1() {
        document.getElementById("circle1").style.r="10";

} 


    </script>


    </head>
    <svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg" >
     <circle id = "circle" cx = "100" cy = "800" r = "30" stroke="blue" stroke-width = "2" fill = "black"/>
     <circle id = "circle1" cx = "20" cy = "500" r = "30" stroke="blue" stroke-width = "2" fill = "black"/>
    </svg>
    <body>
    Set size of circles
    <input type="button" onclick="circle()" value="big" />
    <input type="button" onclick="circle1()" value="small" />
    </body> …
Run Code Online (Sandbox Code Playgroud)

javascript svg dom

2
推荐指数
1
解决办法
5791
查看次数

标签 统计

dom ×1

javascript ×1

svg ×1