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 8587521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:35:22+00:00 2026-06-11T22:35:22+00:00

I have a HTML table a jquery script as given in http://jsfiddle.net/Lijo/Hb28u/4/ . There

  • 0

I have a HTML table a jquery script as given in http://jsfiddle.net/Lijo/Hb28u/4/. There are four jQuery approaches for highlighting table rows. The last two approaches does not work, Why are they not working? I am looking for an explanation in plain English.

HTML

<table id="table1">
<tr> <td>N</td><td>Y</td></tr>  
<tr class="y_n"><td>Q</td><td>N</td></tr>  
</table> 

 <br/><br/>

<table id="table2">
<tr> <td>N</td><td>Y</td></tr>  
<tr class="y_n"><td>Q</td><td>N</td></tr> 
</table> 

<br/><br/>

<table id="table3">
<tr> <td>N</td><td>Y</td></tr>  
<tr class="y_n"><td>Q</td><td>N</td></tr>  
</table> 

 <br/><br/>

<table id="table4">
<tr> <td>N</td><td>Y</td></tr>  
<tr class="y_n"><td>Q</td><td>N</td></tr>  
 </table> 

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js">

SCRIPT

$(document).ready(function()
{


//Apporach 1  - Highlight First Row

$('#table1 tr td:eq(0)').each(function() {
if ($(this).text() == 'N') {
    $(this).parent().css('background-color', 'Orange');
}
});


//Apporach 2 -  - Highlight Second Row

$('#table2 tr td:gt(0)').each(function() {
if ($(this).text() == 'N') {
    $(this).parent().css('background-color', 'Orange');
}
});


//Apporach 3 - Highlight Second Row

$('#table3 tr td:eq(1)').each(function() {
if ($(this).text() == 'N') {
    $(this).parent().css('background-color', 'Orange');
}
});


//Apporach 4 Highlight All Rows

$('#table4 tr td)').each(function() {
if ($(this).text() == 'N') {
    $(this).parent().css('background-color', 'Orange');
}
});

});
  • 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-11T22:35:23+00:00Added an answer on June 11, 2026 at 10:35 pm

    Now it works jsfiddle

    $('#table3 tr td:eq(3)').each(function() { // note that you search for td no. 3 and not 1
       if ($(this).text() == 'N') {
          $(this).parent().css('background-color', 'Orange');
       }
    });
    
    
    //Apporach 4 Highlight All Rows
    $('#table4 tr td').each(function() { // note that in your example you have a ) at the end of the selector
        if ($(this).text() == 'N') {
            $(this).parent().css('background-color', 'Orange');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML table as listed in http://jsfiddle.net/Lijo/sP7zD/ . I need to read
http://jsfiddle.net/Cyjye/ I m new to jquery. I have made html table shown in jsfiddle.Firstly
I have a schedule grid based on a HTML table using jQuery/jQuery UI drag
I have a jQuery ajax call that returns html of a table. Now I
I have a jQuery script with expands a div in a table on click,
I have HTML table on the ASP.NET MVC View page. Now I have to
I have created HTML TABLE from JSON data of PHP using JQuery. After creating
I am using James Padolsey's jQuery sorting script for a HTML table in an
I have the following HTML table. In the last column of each row there
I have HTML table. I'm looping through table and iterate over each row whose

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.