8.7w+
社区成员
var getByClass=function(cla,scope,tag) {//指定tag后在ie中能更快的查找
scope=scope || document;
if(scope.getElementsByClassName)//非IE中,使用原生的效率应该更高
return scope.getElementsByClassName(cla);
tag=tag || "*";
var els=scope.getElementsByTagName(tag);
var length=els.length;
for(var i=0,res=[],l=0,cur;i<length;i++) {
cur=els[i];
if(typeof(cur.className)!=="undefined" && cur.className.search("\\b"+cla+"\\b") != -1) {
res[l++]=cur;//使用索引来访问数组
}
}
return res;
}