Color variation for table cell - Date
Posted: 2023-12-07 15:12
Dear Appgineers,
The code below accomplishes the desired task by turning the cell red in a table if the date is today and beyond. However, it also turns the cell red when the field is blank. How can this be modified in the code?
The code below accomplishes the desired task by turning the cell red in a table if the date is today and beyond. However, it also turns the cell red when the field is blank. How can this be modified in the code?
Code: Select all
<script>
jQuery(document).ready(function() {
var tbody = $j('tbody');
tbody.find('tr').each(function(){
var dateTD = $j($(this).querySelector('.bookings-balance_payment_due_date'));
var date = dateTD.text();
var today = new Date(Date.now()).toLocaleString().split(',')[0]
if (date > today)
dateTD.addClass('danger');
});
});
</script>