Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:50:57+00:00 2026-06-14T08:50:57+00:00

I have two different things that I’m trying to do. I need to change

  • 0

I have two different things that I’m trying to do. I need to change the CSS of a td depending on:

  1. Whether the printed date is earlier than today and
  2. Whether the td just next to this is empty

This is the table I have:

<table><tr>
<td>October 27, 2012</td>
<td id="assigned">Yes</td>
</tr>
<tr>
<td>November 14, 2012</td>
<td id="assigned"></td>
</tr>
</table>

I know I can check whether the <td> is empty or not with jQuery. I also know that I can parse the date that’s on screen. But I can’t seem to get jQuery to iterate through every row in the table. This is the code that I have:

$(document).ready(function () {
$('#myTable tr').each(function(i){
var today = new Date();
var d = Date.parse($("#dueDate").text());
if(d < today && $("td#assigned").text()==""){
$("#dueDate").css("background-color","red");
}});
});

Am I off my rocker? I look at this and I think, it looks like it should work, but it doesn’t. Any help would be appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:50:59+00:00Added an answer on June 14, 2026 at 8:50 am

    looks like the problem seems to be arising because of duplicated ID’s in your HTML ..
    ID’s in a HTML page are supposed to be unique..

    Instead you can use .eq() and $(this) to search for the td

    $(document).ready(function() {
        $('#myTable tr').each(function(i) {
            var $this = $(this);
            var $dueDate = $this.find('td:eq(0)');
            var $assigned = $this.find('td:eq(1)');
            var today = new Date();
            var d = Date.parse( $dueDate.text());
            if (d < today && $assigned.text() == "") {
                $duedate.css("background-color", "red");
            }
        });
    });​
    

    Fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm structuring a database, and found that I have two different objects I'm trying
I have two code blocks that are PHP functions that do two different things.
I have two different things to happen at once.., basically I need to insert
I have found two different things in two well known books in c, first
I have two different tables from which I need to pull data blogs which
I have two function that do the exact same thing in two different ways.
I have two different libGL libraries on the same Ubuntu 11.04 machine. One library
I have two different buttons on my page. I want them both to be
I have two different web applications running on two different instances of tomcat. I
I have two different arrays, one with strings and another with ints. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.