To do the front-end, you need to select elements. The following is the implementation code. A native html element selector is similar to the jquery selector. It is very useful for front-end. You need to select elements, although jquery and various major js libraries have helped me build the wheel, I want to implement one by myself, and the project is not busy, just to add it to my js file, the following is the implementation code. You can call it in the format of $ g ("# content. op"), which is the same as the parameter of jquery $:
Function $ findChilds (parentNode, text) {// if the parent node is not input, the default value is body if (parentNode = undefined) parentNode = document. body; var childNodes = parentNode. childNodes; var results = []; // if (childNodes. length> 0) {var length = childNodes. length; // cyclically query the nodes that match the text (var I = 0; I
After testing in ff ie6, simply selecting id is much faster than jquery,
I tested a few of the other selection modes faster than jquery.
Of course, the test cannot be comprehensive, there may be bugs, and pseudo-class choices like. content: first-child are not supported.