<div class="codetitle"> <span><a style="CURSOR: pointer" data="35497" class="copybut" id="copybut35497" onclick="doCopy('code35497')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code35497"> <br>function getElementsByClassName(n) { <br>var classElements = [],allElements = document.getElementsByTagName('*'); <br>for (var i=0; i{ <br>if (allElements[i].className == n ) { <br>classElements[classElements.length] = allElements[i]; <br>} <br>} <br>return classElements; <br>} <br> </div>