Find all cells within a specific column and change color on certain characters
I need to perform the following on my table:
- Find a specific column by it's name or class (<th class="ColHeader1" scope="col">ColHeader1</th>)
- Within that column I need to find all the cells containing "1"
- The cell could contain a string like "1, 2, 3", and then I need to set the color red only on "1".
How can I do this with JQuery?
So here is the table:
-
- <table class="fooBar" width="200" border="0">
- <thead>
- <tr>
- <th class="ColHeader1"><b>ColHeader1</b></th>
- <th class="ColHeader2"><b>ColHeader2</b></th>
- <th class="ColHeader3"><b>ColHeader3</b></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>1, 2, 3</td>
- <td>CellData</td>
- <td>CellData</td>
- </tr>
- <tr>
- <td>1, 2, 3</td>
- <td>CellData</td>
- <td>CellData</td>
- </tr>
- <tr>
- <td>1, 2, 3</td>
- <td>CellData</td>
- <td>CellData</td>
- </tr>
- </tbody>
- </table>
So this is the result I would expect: