1
Good afternoon to you all! I have a table with this information:
<tr>
<td>Origem</td>
<td>Destino</td>
<td>Status</td>
</tr>
<tr class="status" data-status="<?php echo $linha['status'];?>">
<td>SP</td>
<td>MG</td>
<td>C</td>
</tr>
In jquery, I have a code that returns the values like this:
(5) ["M", "C", "C", "C", "C"]
What I need is that when the value of the "status" column is "M", the row has a color and when the value of the "status" column is "C", the row has another color.
My code is like this, but with this code all the lines are one color.
var status = new Array();
$('.status').each( function( i ){
var $this = $( this )
status[i] = $this.attr('data-status');
if(status[i] == "M"){
$('.status').addClass('livre');
}else if(status[i] == "C"){
$('.status').removeClass('livre').addClass('ocupado');
}
});
console.log(status);
Someone can help in this case?
Thank you very much!