// 网上参考的,自己修改了一部分
// 代码如下,纯JS,要求浏览器支持 getElementsByClassName 方法
<script type="text/javascript"> function getElementsByClassName(classname,node){ node = node || window.document; if(node.getElementsByClassName){ return node.getElementsByClassName(classname); }else{ var results = new Array(); var elems = node.getElementsByTag("*"); for (var i=0;i<elems.length;i++){ if(elems[i].className.indexOf(classname) != -1){ results[elems.length] = elems[i]; } } return results; } }; </script>