<div id="u">
<div class="div_1"></div>
<div class="div_1"></div>
<div class="div_1"></div>
</div>
function chgclass(o) {
var u = document.getElementById('u');
var c = u.childNodes;
for (var i = 0; i < c.length; i++) {
if (c[i].tagName && c[i].tagName.toLowerCase() == 'div') {
if (c[i] == o) {
c[i].className = 'div_2';
} else {
c[i].className = 'div_1';
}
}
}
}
本文转自 沉淀人生 51CTO博客,原文链接:http://blog.51cto.com/825272560/1891150