我想改变一类元素的颜色。
例子:
<transform translation='-2 0 0'>
<shape id="N0_0_0">
<appearance>
<material class="L2_0_0_3 L2_0_0_2" diffuseColor='1 0 0'></material>
</appearance>
<box size='0.5,0.5,0.5'></box>
</shape>
</transform>
<transform translation='2 0 0' >
<shape id="N2_0_0">
<appearance>
<material class="L2_0_0_3 L2_0_0_1" diffuseColor='1 0 0'></material>
</appearance>
<box size='0.5,0.5,0.5'></box>
</shape>
</transform>
当发生特定事件时(在我的例子中是元素的 onMouseOver 事件),我想更改“matT1”类的所有元素的颜色。到目前为止,我尝试更改第一个元素的颜色,但它不起作用。
document.getElementsByClassName("matT1")[0].prop('diffuseColor', '0 0 1');