Determining if shown dates in a table are before today's date using jQuery

Tags: jquery,css

Problem :

I'm looking for help to accomplish this seemingly simple task. I just don't have the know-how to figure this out.

Basically, I have a form that I select a date (for the due date) for a work order from jQuery's datepicker. The results are displayed on a separate page in a table with other work orders.

I am trying to figure out how to determine if the shown date in the table is past due or not and change the CSS if the date is before today's date. Because there are several rows in the table and each row has a due date that needs to be evaluated, this has stumped me.

<td class="dueDate">November 1, 2012</td>
<td class="dueDate">November 4, 2012</td>
<td class="dueDate">November 26, 2012</td>

This is the layout of the table when the form is displayed. And this is the closest that I can think to put together to determine if the date displayed is before today's date or not.

var dueDate = $(this).val();
var today = new Date();
if (Date.parse(dueDate) < Date.parse(today)){

This doesn't seem to be working. Any ideas?

Solution :

Try Date.parse

  if (Date.parse(dueDate) < Date.parse(today)) {
      $(".dueDate").addClass("pastDue");// . for class

    CSS Howto..

    How to center a 3 column Css Div Site?

    How to Block a Page from Picking up a .css file?

    How to get my navbar to fluidly contain the largest element?

    how to make a div stay in a div

    How to have a box increase its size based on its content?

    How to version files in the section?

    How can I add pagination to my site's gallery?

    How does CSS3 flexbox negative-flex work?

    twitter-bootstrap: how to get rid of underlined button text when hovering over a btn-group within an -tag?

    How do you style an android app?

    How can I add a default to my CSS slide show banner?

    How to apply css class to an html element using jquery in ASP .NET MVC?

    How to add a class to a menu item that has children

    How to add space to left-right of the Web-Page using HTML/CSS

    How can I programmatically (in JavaScript) add “sub-divs” to divs?

    How do i apply fadein and fadeout effect for this?

    How to vertically align text over an image

    How to remove dotted border around active hyperlinks in IE8 with CSS

    How to position elements with flex [duplicate]

    How to segregate these divs with 'position:absolute' into different groups?

    How to style a “list item > link” in jquery mobile

    How to achieve this layout with div and css?

    How to style a particular paragraph element in css without effecting the other paragraphs in the same class?

    How do you maintain CSS layout when adding content (ASP.NET)

    CSS clearfix how to over come the inability to center an element using it

    How to add Print headers and footers in HTML, CSS and JavaScript?

    How to apply a CSS style to div AND the div nested in the div [duplicate]

    How to properly center steps in bootstrap?

    How to change color of disabled html controls in IE8 using css

    How to increase the distance between table columns in html?