I am facing an issue with a script that applies a CSS class to table cells if the date is greater than a certain value. Currently, the script only works for today's date. I need it to work for dates within and outside of this week as well.
$('td:nth-child(7)').each(function() {
var today = new Date();
var week = new Date();
var dd = today.getDate();
var ddd = today.getDate()+7;
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
if(dd<10) {
dd = '0'+dd
}
if(mm<10) {
mm = '0'+mm
}
today = dd + '/' + mm + '/' + yyyy;
if ($(this).text() == today) {
$(this).closest("td").addClass("red");
}
if ($(this).text() < today + 7 && $(this).text() != today ) {
$(this).closest("td").addClass("yellow");
}
if ($(this).text() > today + 7) {
$(this).closest("td").addClass("green");
}
});