So I have an HTML table displaying the results from a query. A sample of the table is as follows:
<div class="timecard">
<tr class = "display-even-row">
<td align="left" style="color:#000099">2400-Duffy's</td>
<td align="left" class="hrs">4</td>
<tr class = "display-odd-row">
<td align="left" style="color:#009900">1500-Orchard</td>
<td align="left" class="hrs">2</td>
</div>
I want to total the "hrs" class separately for the 2400-Duffy's records and the 1500-orchard records. The following is the JQuery statement I am trying to use.
var sum=0
$(".hrs").each(function(i) {
if($('style') == 'color#000099') {
sum = sum + parseInt($(this).text());
}else if ($('style') == 'color#009900' {
sum2 = sum + parseInt($(this).text());
});
$(".total").append("Total Duffy hours: " + sum);
$(".total").append("Total Orchard hours: " + sum2);
However, the above does not work properly and honestly I'm trying to automate it more as it has more that one "job code" than just the two listed above. Any suggestions would be great. thanks.