我有单独的包含 SVG 路径 ID 的 json。有没有办法使用路径 id 获取 SVG 路径“d”属性?或者有没有办法只使用路径 Id 来填充 SVG 路径?
最佳答案
您可以通过调用 document.getElementById 来获取路径元素,然后您可以从那里获取/设置属性...
var d = document.getElementById("<path id>").getAttribute("d");
document.getElementById("<path id>").setAttribute("fill", "red");
关于javascript - 使用路径id获取SVG路径d属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48485221/