change background-color td with jquery
javascript, jquery
Solution
You can use the nth selector in jQuery:
http://api.jquery.com/nth-child-selector/
$( "table tr:nth-child(2) td:nth-child(1)" ).css("background-color", "blue");
$( "table tr:nth-child(3) td:nth-child(1)" ).css("background-color", "blue");
$( "table tr:nth-child(4) td:nth-child(1)" ).css("background-color", "blue");
$( "table tr:nth-child(5) td:nth-child(1)" ).css("background-color", "blue");
jsFiddle
Problem
how to change background-color td with jquery ? I need to change the background-color column one in row two and three and four my table : ``` <table class="myTable"> <thead> <tr> <th>Col 1</th> <th>Col 2</th> <th>Col 3</th> <th>Col 4</th> </tr> </thead> <tbody> <tr> <td>td1</td> <td>td2</td> <td>td3</td> <td>td4</td> </tr> <tr> <td >td1</td> <td>td2</td> <td>td3</td> <td>td4</td> </tr> <tr> <td>td1</td> <td>td2</td> <td>td3</td> <td>td4</td> </tr> <tr> <td>td1</td> <td>td2</td> <td>td3</td> <td>td4</td> </tr> <tr> <td>td1</td> <td>td2</td> <td>td3</td> <td>td4</td> </tr> </tbody> </table> ``` demo : jsfiddle How to do it with jQuery?