jQuery交替行颜色

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery交替行颜色相关的知识,希望对你有一定的参考价值。

This one is simple yet very useful. You can do alternating row colors with 2 simple lines of jQuery
  1. //jquery
  2. $('div:odd').css("background-color", "#F4F4F8");
  3. $('div:even').css("background-color", "#EFF1F1");
  4.  
  5.  
  6. //html example
  7. <div>Row 1</div>
  8. <div>Row 2</div>
  9. <div>Row 3</div>
  10. <div>Row 4</div>
  11.  
  12. //you can use td, tr, li, etc..

以上是关于jQuery交替行颜色的主要内容,如果未能解决你的问题,请参考以下文章