<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‘;
}
}
}
}
本文出自 “不凡人生——求知者” 博客,转载请与作者联系!
原文:http://825272560.blog.51cto.com/11004487/1891150