Given a table with a column “DueDate”, what would be the approximate jQuery code for say, setting the backcolor of the table rows based on the value of each DueDate cell with respect to another date?
I am most specifically interested in the pitfalls involving how to properly handle the dates….how to consume a string value explicitly as a date in javascript, do I have to be very strict with the date formatting, etc.
Given that you are able to convert the dates to seconds (or milliseconds) using
Date.parse(), you can then use something like this:If it isn’t clear from the code, this snippet will first find the minimum and maximum dates, then color the rows so that the minimum date is red and maximum green.
Hope this helps.