<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title></title></Head><Body><inputtype= "button"value= "discoloration"ID= "BT"/><ulID= "UU"> <Li>Braised carp in soy sauce</Li> <Li>Sweet and sour pork ribs</Li> <Li>Braised Eggplant</Li> <Li>Hot and sour potato shreds</Li> <Li>Spicy crayfish</Li> <Li>Northeast Roast Cold Noodles</Li> <Li>Shaanxi Meat Pinch bun</Li> <Li>Yunnan Bridge Noodle</Li></ul><Scriptsrc= "Common.js"></Script><Script> //Interlaced Colormy$ ("BT"). onclick= function () { varCount= 0;//record the number of Li //get all the child nodes in UL varnodes=my$ ("UU"). ChildNodes; for (varI= 0; I<nodes.length; I++) { //determine if this node is Li if(Nodes[i].nodetype== 1 &&Nodes[i].nodename== "LI") {Nodes[i].style.backgroundcolor=Count% 2 == 0 ? "Red" : "Yellow"; Count++; } } };</Script></Body></HTML>
The way the JavaScript nodes are interlaced