没加过滤器之前:

jQuery的基本过滤器与jQuery实现隔行换色实例

 

加过滤器之后:

jQuery的基本过滤器与jQuery实现隔行换色实例

总的代码:

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title>奇数与偶数过滤器的基本应用</title>
 6         <script src="js/jquery-3.3.1.js"></script>
 7         <script>
 8             $(function(){
 9                 $("div:even").css("background-color","aquamarine");//修改索引为偶数的背景    颜色
10                 $("div:odd").css("background-color","aqua");//修改索引为奇数的背景颜色
11         
12                 
13             })
14         </script>
15     </head>
16     <body>
17         <div>
18             索引0:欢迎来到perfect*的博客世界
19         </div>
20         <div>
21             索引1:欢迎来到perfect*的博客世界
22         </div>
23         <div>
24             索引2:欢迎来到perfect*的博客世界
25         </div>
26         <div>
27             索引3:欢迎来到perfect*的博客世界
28         </div>
29         <div>
30             索引4:欢迎来到perfect*的博客世界
31         </div>
32         <div>
33             索引5:欢迎来到perfect*的博客世界
34         </div>
35         <div>
36             索引6:欢迎来到perfect*的博客世界
37         </div>
38         <div>
39             索引7:欢迎来到perfect*的博客世界
40         </div>
41     </body>
42 </html>
jQuery偶数奇数过滤器.html

相关文章:

  • 2021-09-02
  • 2021-08-24
  • 2022-12-23
  • 2021-12-13
  • 2021-11-02
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
猜你喜欢
  • 2022-01-16
  • 2021-11-18
  • 2021-08-04
  • 2022-12-23
  • 2022-02-15
  • 2021-09-29
相关资源
相似解决方案