/**
* @author Supersha
* @QQ:770104121
*/
var cssQuery = {
//parent: Used to store the reference of the parent node of the current node
parent: document,
select: function(selectorStr){
var selectors=(" "); //Separate strings
for (var i = 0, len = ; i < len; i++) {
var el = || document; // Used to store node references for specified class attributes
var val=(selectors[i]); //Replace the "#" and "." points to get the node reference of the specified ID
if ( == 1) { //If there is only one parameter
if (!(/[#.]/g).test(selectors[i])) { //If it is an HTML tag
return (selectors[i]);
}
else { //If it is an ID or specified class value
//Judge whether it is an ID or a class attribute
return ((selectors[i])) ? this.$(val) : (document, "*", val);
}
}
//If the last ID or class or HTML tag is reached in the selectorStr character is reached
else if(i == -1){
if (!(/[#.]/g).test(selectors[i])) { //If it is an HTML tag
return (selectors[i]);
}
else { //If it is an ID or class attribute
return ((selectors[i])) ? this.$(val) : (el,"*",val);
}
}
else{ //If there are more than two levels of selectorStr, the reference of the current node is stored in the parent property.
if (!(/[#.]/g).test(selectors[i])) { //If it is an HTML tag
= (selectors[i])[0];
}
else { //If it is an ID or class attribute
= ((/#/gi).test(selectors[i])) ? this.$(val) : el;
}
}
}
},
$: function(id){ // Used to get a reference to the specified ID
return (id);
},
IDLabel: function(selector){ //Judge whether it is an ID attribute
return ((/#/gi).test(selector)) ? true : false;
},
classLabel: function(selector){ //Judge whether it is a class attribute
return ((/\./gi).test(selector)) ? true : false;
},
replaceStr:function(a){ //Replace the "#" and "." points to get the node reference of the specified ID
return ("#","").replace(".","");
},
getElementsByClassName: function(el, tag, classname){ //Get the reference of the element containing the class attribute value through the class attribute value
var elem = el || document;
if (!classname)
return;
tag = tag || "*";
var allTagsDom = ((tag == "*") && ()) ? : (tag);
classname = (/\-/g, "\\-");
var regex = new RegExp("(^|\\s*)" + classname + "(\\s*|$)");
var matchElements = new Array();
var element;
for (var i = 0; i < ; i++) {
element = allTagsDom[i];
if (()) { //Check class names according to regularity
(element);
}
}
return matchElements;
}
}
//Calling method: (selectorString); selectorString Like this: "#p #b .em",
//It can receive a combination of HTML tags, IDs, and class, and return a reference to the specified selectorString