I try to learn as much as I can from this sort of exercise. I made a couple of revisions to previously untested version, went back and made a couple of syntax and code fixes to previously untested suggestion I only submit this because it works on a limited sized table with simple names, not suggesting that it is highly efficient or not, and always open to learning why something isn;t efficient. Have been told in past not to use attr() but still not sure why. tested this in FF and IE live version : http://jsbin.com/ayaji js: $(document).ready(function() { var colorArray=["red","blue","green","orange","black"]; var colorCount=0; $("# table 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{ if(colorCount>4){ colorCount=0 } $(this).addClass(classname).css("color",colorArray[colorCount] ) colorCount++ } }); }); Bi Jing wrote: I like this issue and following is my draft implement, its working on IE/FF, hope it helps |
- [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
- [jQuery] Re: Change row colors of table based o... Bi Jing
- [jQuery] Re: Change row colors of table bas... Charlie
- [jQuery] Re: Change row colors of table bas... Charlie
- [jQuery] Re: Change row colors of table... gjha...@gmail.com