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

  • Home
  • SEARCH
  • 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 8535951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:33:09+00:00 2026-06-11T10:33:09+00:00

I have a pretty basic table at the moment: I need to be able

  • 0

I have a pretty basic table at the moment:

enter image description here

I need to be able to only hightlight one row in each column, and deselect whatever was selected before it..

I understand I’m going to need a CSS class, e.g.

 .hightlighted {
 background: #f00;
 color: #fff;
 }  

The HTML in the view is pretty basic also:

<tbody>
<tr>
<td> </td>
<td>Differdange</td>
<td> </td>
</tr>       
    <tr>
<td> </td>
<td>Dippach</td>
<td> </td>
    </tr>
<tr>
<td> </td>
<td>Dudelange</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Echternach</td>
<td></td>
</tr>
<tr>
<td> </td>
<td>Erpelscheid</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Esch-sur-Alzette</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Esch-sur-Sûre</td>
<td> </td>
</tr>
    <tr>
<td> </td>
<td>Ettelbruck</td>
<td> </td>
</tr>
    <tr>
<td> </td>
<td>Feulen</td>
<td> </td>
</tr>
</tbody

But I don’t know whether it’s appropriate to highlight/unhighlight rows in CSS if I am going to be needing to ‘grab’ the selected data from the rows when the table is completed by the user?

Can anyone suggest what I should use (JQuery, Javascript, CSS) to highlight a row in a column so that I can get the data later?

EDIT

Now I’ve got the highlighting sorted, the only problem I’m having is differentiating between columns so that instead of this (which I’m getting atm)

enter image description here

I want each columns to be able to have it’s own unique row highlighted (e.g. Differdange could be highlighted, as well as dddd on Localities)

Any way to edit the

$("tr").click(function() {
$("tr").removeClass("highlighted");
$(this).addClass("highlighted");
});

code to do this? 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-11T10:33:10+00:00Added an answer on June 11, 2026 at 10:33 am

    You can use the .removeClass() and .addClass() jQuery methods to achieve this. Here’s a little demo: little link. The code is pretty self-explaining, but here’s a commented version of the JavaScript part:

    var chosen = []; //an array to save the chosen row for each column
    $("td").click(function() { //when a td is clicked
        var idx = $(this).index() + 1; //get column of current cell
        $("td:nth-child(" + idx + ")").removeClass("highlighted"); //unhighlight all cells in column
        $(this).addClass("highlighted"); //highlight this one
        chosen[idx] = $(this).parent("tr").index(); //and save it as chosen in its column
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a report pretty basic just a table wiht 45 rows of
Its a pretty basic scenario. I have a table with a Geography datatype in
This should be pretty basic but i can't figure it out. Have a table
I have a page that creates a table using backbone.js. each table row is
I might have pretty basic question about regex. I have the following regex, which
I have a pretty basic challenge-based iPhone game, and I wanted to know what
I have a pretty basic doubt on dirty read/writes to a value stored in
I have a pretty basic problem but I can't seem to figure it out...
Pretty basic programming question, I know PHP have a function for it, but does
I realize this question is pretty basic, but I'm really stuck. I have a

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.