标签:
<span style="font-family:Microsoft YaHei;font-size:18px;">clsname是要获取元素的类名,parentId是要获取父元素id</span>
<span style="font-family:Microsoft YaHei;font-size:18px;"> </span>
<span style="font-family:Microsoft YaHei;font-size:18px;">function getElementsByClassName(clsname,parentId){ var p = parentId?document.getElementById(parentId):document, elements = [], sonEle = document.getElementsByTagName("*"); for(var i = 0;i<soneEle.length;i++){ if(sonEle[i].className==clsname){ elements.push(sonEle[i]); } } return elements; }</span>
标签:
原文地址:http://blog.csdn.net/ring_to_ping/article/details/46362923