有没有办法用 JS 更改所有按钮的类值?现在我有:
var nodes = document.getElementsByClassName("yui-button yui-radio-button");
然后是一个 for 循环
for (i=0;i<nodes.length;i++) {
nodes[i].className = "something";
}
有没有绕过for循环并更改所有类值?
这是html:
<div id="season" align="center">
<div id="seasonButtons" class="yui-buttongroup">
<span id="yui-gen0" class="yui-button yui-radio-button">
<span class="first-child">
<button type="button" id="yui-gen0-button">Spring</button>
</span>
</span>
<span id="yui-gen1" class="yui-button yui-radio-button">
<span class="first-child">
<button type="button" id="yui-gen1-button">Summer</button>
</span>
</span>
<span id="yui-gen2" class="yui-button yui-radio-button">
<span class="first-child">
<button type="button" id="yui-gen2-button">Fall</button>
</span>
</span>
</div>
</div>