我想要更改以下元素的样式:
<path d="M0 573.96 L0 595.28 L64.96 595.28 L64.96 573.96 L0 573.96 L0 573.96 Z" class="st8"/>
完整的svg代码:
<g id="shape487-256" v:mID="487" v:groupContext="shape" transform="translate(707.533,-425.236)">
<title>Sheet.487</title>
<desc>Claims Management</desc>
<v:textBlock v:margins="rect(4,4,4,4)" v:tabSpace="42.5197"/>
<v:textRect cx="32.478" cy="584.619" width="64.96" height="21.314"/>
<path d="M0 573.96 L0 595.28 L64.96 595.28 L64.96 573.96 L0 573.96 L0 573.96 Z" class="st8"/>
<text x="21.21" y="582.22" class="st9" v:langID="1033"><v:paragraph v:horizAlign="1"/><v:tabList/>Claims <tspan
x="9.92" dy="1.2em" class="st10">Management</tspan></text> </g>
我只改变了文本的笔画,而没有改变背景颜色。简单地设置fill是没有效果的,所以我想删除st8类,但是我得到消息path.removeAttribute不是一个函数。
function highlightTrend01(){
//Claims Management
var e = document.getElementById("shape487-256");
// e.setAttribute("stroke","blue"); setting stroke works
var paths = e.getElementsByTagName("path");
paths.removeAttribute("class");
paths.style["fill"] = "orange";
}
发布于 2019-03-14 18:11:46
要删除类,请使用:
paths.classList.remove("st8");
它不会删除属性,但我想在这种情况下这并不重要。
https://stackoverflow.com/questions/55159744
复制相似问题