I add JavaScript to a wiki page which has a web-part of list. I want all even rows in the list display background color in green. There are 10 pages in this web-part. But the script just works for the first page.

How can I change color for all pages?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

$("tr:even").css("background-color", "green");});
  • 2
    Can you post a screen shot? Apr 28, 2015 at 14:41
  • @AmalHashim Thank you!!! I change the script, I use CSS directly. '#MSOZoneCell_WebPartWPQ2 .ms-alternating { background-color: Tan; } </style>'
    – AnnaCICI
    Apr 28, 2015 at 15:05
  • @AmalHashim your photo is good !
    – AnnaCICI
    Apr 28, 2015 at 15:07
  • Thanks MKQian. If you can post your solution as an answer it might help the community. Apr 28, 2015 at 15:08

1 Answer 1


I change the script, I use CSS directly. It works well

#MSOZoneCell_WebPartWPQ2 .ms-alternating 
{ background-color:  green; } 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.