Good afternoon everyone! 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 status column value is "M", the line has a color and when the status column value is "C", the line 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);
Can anyone help in this case?
Thank you!