gpt4 book ai didi

javascript - 如何使用 javascript 移动 SVG 线

转载 作者:行者123 更新时间:2023-11-28 15:38:02 26 4
gpt4 key购买 nike

我不知道如何在 JavaScript 中从 SVG 元素设置 x1、y1、x2、y2 参数。

<svg height="210" width="500">
<line id="line" x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
</svg>

感谢您的帮助。

最佳答案

只是

var line = document.getElementById("line");
line.setAttribute("x1", "5");

等等

关于javascript - 如何使用 javascript 移动 SVG 线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24975475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com