I am trying to change the background of a cell in a css grid based on a value of a div that is pulled from a php database query.I'm using jquery to achieve the same function with another div, but the only difference is the value that is being compared is the same div in the css. Here is the div structure for the html. box datetime is a child of box a.
<div class='box a'>
<div class='box name'><a style='text-decoration:none; color:#444;' href='foobar.com' target='_blank'>Proper Name</a></div>
<div class='box mm'>75.49</div>
<div class='sog'>10.2</div>
<div class='box datetime'>1</div>
Here is the function i'm using.
$('.datetime').each(function(index, value) {
var value = Number($(this).text());
console.log(value);
if (value < 4)
$('.a').css('background-color', '#fff');
else if (value >= 4 && value <= 15)
$('.a').css('background-color', 'orange');
else
$('.a').css('background-color', 'purple');
});
.datetimeis a whole number that represents the number of minutes bewteen 2 times..ais the css grid cell that i want to change the css properties of.
Right now, it will only turn all of the .a background color to #fff. It will not evaluate correctly. What am I doing wrong?