Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试更改 SVGPathElement 的颜色,但它不会刷新。我检查它是否获得了显示警报的新颜色,但我没有看到任何区别。是因为我的 SVG 被 AJAX 检索了吗?
var element = document.getElementById(id); alert(element.getAttribute("stroke")); element.setAttributeNS(null, "stroke", "#000000");
提前致谢
您可以尝试使用样式设置笔画:
element.style.stroke='#0000';