The way the JavaScript nodes are interlaced

Source: Internet
Author: User

<!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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.