jq实现超级简单的隔行变色
Posted sandraryan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jq实现超级简单的隔行变色相关的知识,希望对你有一定的参考价值。
文章地址:https://www.cnblogs.com/sandraryan/
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> p{ margin: 0; line-height: 26px; } </style> </head> <body> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <p>this is a sentence.</p> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> <script> // p中的奇数行偶数行设置不同的颜色 $("p:odd").css("backgroundColor","white"); $("p:even").css("backgroundColor","lightblue"); </script> </body> </html>
以上是关于jq实现超级简单的隔行变色的主要内容,如果未能解决你的问题,请参考以下文章