(function(global){
var QueryName = function(selector){
var arr=[];
if(){
}else if(){
}else{
}
return arr;
}
global.$ = global.QueryName = QueryName;
})(typeof window !== 'undefined'?window:this)
示例
(function(global){
var woQuery=function(selector){
var arr=[];
if(typeof selector==='string'){
var strIndex=selector.substring(0,1);
if(strIndex==='#'){
var strId=selector.substring(1,selector.length);
arr.push(document.getElementById(strId));
}else if(strIndex==='.'){
var strClass=selector.substring(1,selector.length);
var classNames=document.getElementsByClassName(strClass);
for(var i=0;i<classNames.length;i++){
arr.push(classNames[i]);
}
}else{
var tagNames=document.getElementsByTagName(selector);
for(var i=0;i<tagNames.length;i++){
arr.push(tagNames[i]);
}
}
}
return arr;
}
global.$ = global.woQuery = woQuery;
})(typeof window !== 'undefined'?window:this);