document.getElementsByClassName=function(className,oBox){
//适用于获取某个HTML区块内部含有某一特定className的所有HTML元素
this.d=oBox||document;
varchildren=this.d.getElementsByTagName('*')||document.all;
varelements=newArray();
for(varii=0;ii
varclassNames=child.className.split('');
for(varj=0;j
elements.push(child);
break;
}
}
}
returnelements;
}
document.getElementsByType=function(sTypeValue,oBox){
//适用于获取某个HTML区块内部同属于某一特定type的所有HTML元素,如:input,script,link等等
this.d=oBox||document;
varchildren=this.d.getElementsByTagName('*')||document.all;
varelements=newArray();
for(varii=0;ii
elements.push(children[ii]);
}
}
returnelements;
}
function$(){
varelements=newArray();
for(varii=0;ii
if(typeofelement=='string')
element=document.getElementById(element);
if(arguments.length==1)
returnelement;
elements.push(element);
}
returnelements;
}
$Cls=function(s,o){
returndocument.getElementsByClassName(s,o);
};
$Type=function(s,o){
returndocument.getElementsByType(s,o);
};
$Tag=function(s,o){
this.d=o||document;
returnthis.d.getElementsByTagName(s);
};
$Name=function(s){//通过name的方式只能针对整个document而言,不能为其限定范围
returndocument.getElementsByName(s);
};