my starting thought would be use the name as a class, assign a color to
class perhaps from an array of colors so you could have 10 colors and
use them in order for first ten unique names, then repeat for next 10
unique names use a length ( or size) test to see if that class already exists, if it does, get the css from the first element with that class [grab the attr("style") ], don't use a new color and go to next name this is really rough and untested: var colorArray=["red","blue" etc ///setup color array, assuming 10 colors for code below] var colorCount; $("#yourTable tr").each(function() { var classname= $(this).find("td").eq(1).text(); if ($("."+classname).length >0) { var thisStyle=$("."+classname +).eq(0).attr("style") $(this).attr("style", thisStyle) }else{ colorCount++ if(colorCount>9){ colorCount=0 } $(this).addClass("classname").css("color", colorArray[colorCount]) } }); Gewton Jhames wrote: Anybody want to discuss a way to change row colors of table based on content, for example: |
- [jQuery] Change row colors of table based on content Gewton Jhames
- [jQuery] Re: Change row colors of table based on co... Jeffrey Kretz
- [jQuery] Re: Change row colors of table based on co... Charlie