<! DOCTYPE html> <html lang="en">
<head>
    <meta charset="UTF-8"</ style>. Blue {color: blue; } < / style > < / head > < body > < ul > < li > item 1 < / li > < li > 2 < / li > < li > project 3 < / li > < li > project 4 < / li > < li > project 5 < / li > < / ul > < script > window.jQuery =function(nodeOrSelector){// The argument passed in is a string or nodeletNodes = {} // Pseudo-array nodes saves one or more nodes corresponding to the selectorif(typeof nodeOrSelector === 'string') {letTemp = document. QuerySelectorAll (nodeOrSelector) / / return nodeList pseudo arrayfor(leti=0; i<temp.length; I ++){// Do not want redundant prototype chain, Nodes prototype chain points directly to Object Nodes [I] = temp[I]} nodes.length = temp.length}else if(nodeOrSelector instanceof Node){
                    nodes = {
                        0: nodeOrSelector,
                        length: 1
                    }
            }
            nodes.addClass = functionForEach ((value) => {// Add all classes to nodes (hash)for(leti=0; i<nodes.length; I ++){// iterate over all nodes, that is, add class Nodes [I].classlist.add (value)}})} nodes.text = to all nodesfunction(text){// Add the text property to the Nodes object (hash)if(text === undefined){// Get var texts = []for(let i=0; i<nodes.length; i++){
                    texts.push(nodes[i].textContent)
                    }
                    return texts
                }else{// The parameter is setfor(let i=0; i<nodes.length; i++){
                        nodes[i].textContent = text
                    }
                }
            }
            returnNodes // returns node2} window.$= jQuery var$node2 = $('ul > li') // node2 is equal to the value returned by the jQuery function (pure pseudo-array nodes)$node2.addClass(['blue'.'a'.'b'.'c'] // Multiple class names can be added$node2.text('hi')
        console.log($node2)
        console.log($node2TextContent </script> </body> </ HTML >Copy the code