CSS and JS processing the problem of interlaced color change

Source: Internet
Author: User

 
  1. <html>
  2. <head>
  3. <meta charset="Utf-8">
  4. <meta name= "" content="Content">
  5. <meta name="viewport" content= "width=device-width, initial-scale=1.0,maximum-scale= 1.0, User-scalable=no "/>
  6. <title></title>
  7. <link rel="stylesheet" type= "text/css" href= ">
  8. <script src="Js/jquery1.8.3.min.js"></script>
  9. </head>
  10. <script>
  11. /*$ (document). Ready (function () {
  12. $ ('. Product_tit:even '). css ({"Color": "#21c178"});
  13. $ ('. Product_tit:odd '). css ({"Color": "#459ee6"});
  14. })*/
  15. </Script>
  16. <div> <span style="White-space:pre"> </span> <style>
  17. <span style="White-space:pre"> </span> #list2: Nth-of-type (Odd). Product_tit{color: #21c178}
  18. <span style="White-space:pre"> </span> #list2: Nth-of-type (even) . Product_tit{color: #459ee6}
  19. <span style="White-space:pre"> </span></style> </Div> <body>
  20. <style type="Text/css">
  21. . List1:nth-of-type (odd) {color: #ffcc00;}
  22. . List1:nth-of-type (even) {color: #00ccff;}
  23. </style>
  24. <div>
  25. <ul>
  26. <li class="List1">111111111111111111111111111</li>
  27. <li class="List1">222222222222222222222222222</li>
  28. <li class="List1">333333333333333333333333333</li>
  29. <li class="List1">444444444444444444444444444</li>
  30. <li class="List1">555555555555555555555555555</li>
  31. <li class="List1">666666666666666666666666666</li>
  32. </ul>
  33. <hr />
  34. <div id="List2">
  35. <div class="Product_tit">7777777777777777777777777777</div>
  36. </div>
  37. <div id="List2">
  38. <div class="Product_tit">8888888888888888888888888888</div>
  39. </div>
  40. <div id="List2">
  41. <div class="Product_tit">9999999999999999999999999999</div>
  42. </div>
  43. <div id="List2">
  44. <div class="Product_tit">0000000000000000000000000000</div>
  45. </div>
  46. <div id="List2">
  47. <div class="Product_tit">7777777777777777777777777777</div>
  48. </div>
  49. </div>
  50. </Body>
  51. </html>

Note: Add jquery yourself

The wrong CSS:

[HTML]View PlainCopy
    1. <style>
    2. . Product_tit:nth-of-type (odd) {color: #21c178}
    3. . Product_tit:nth-of-type (odd) {color: #459ee6}
    4. </style>

Cause of the error: each element of Class=product_tit has no sibling node, Nth-of-type does not work


CSS and JS processing the problem of interlaced color change

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.