HTML
<table id="myTable">
<tr><td>Id</td><td>Jack</td><td>Group</td></tr>
<tr><td>1</td><td>Sarah</td><td>1</td></tr>
<tr><td>2</td><td>Teddy</td><td>2</td></tr>
<tr><td>3</td><td>John</td><td>3</td></tr>
<tr><td>4</td><td>Reag</td><td>1</td></tr>
</table>
jQuery
$(document).ready(function(){
var currentGroup = "Group";
$("table tr").each(function() {
if($(this).find('td:eq(2)').text()==currentGroup){
$("td:eq(2)").css('color','red');
}
});
});
Result
<table id="myTable">
<tr><td>Id</td><td>Jack</td><td>Group</td></tr>
<tr><td>1</td><td>Sarah</td><td>1</td></tr>
<tr><td>2</td><td>Teddy</td><td>2</td></tr>
<tr><td>3</td><td>John</td><td>3</td></tr>
<tr><td>4</td><td>Reag</td><td>1</td></tr>
</table>
jQuery
$(document).ready(function(){
var currentGroup = "Group";
$("table tr").each(function() {
if($(this).find('td:eq(2)').text()==currentGroup){
$("td:eq(2)").css('color','red');
}
});
});
Result
Id | Jack | Group |
1 | Sarah | 1 |
2 | Teddy | 2 |
3 | John | 3 |
4 | Reag | 1 |
No comments:
Post a Comment