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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:52:13+00:00 2026-06-18T05:52:13+00:00

I have 2 tables in a div and I would like to highlight the

  • 0

I have 2 tables in a div and I would like to highlight the same row on both tables at the same time. Right now I only managed to get it to highlight columns and rows in 1 table.

(example: If i hover over “Row2 Column3” in tbl-2, Row2 in tbl-1 should be highlighted and viceversa)

Also how do i get it to highlight the th tag too?

<div class="row">
<div class="span2 pull-left">
    <table class="table table-bordered pull-left" id="compare-tbl-1">
        <thead>
            <th>Column 1</th>
        </thead>
        <tbody>
            <tr>
                <td>
                    Row1
                </td>
            </tr>
            <tr>
                <td>
                    Row2
                </td>
            </tr>
            <tr>
                <td>
                    Row3
                </td>
            </tr>
            <tr>
                <td>
                    Row4
                </td>
            </tr>
            <tr>
                <td>
                    Row5
                </td>
            </tr>
        </tbody>
    </table>
</div>
<div class="span10 pull-right">
    <table class="table table-bordered" id="compare-tbl-2">
        <thead>
            <th>Column 1</th><th>Column 2</th><th>Column 3</th><th>Column 4</th><th>Column 5</th>
        </thead>
        <tbody>
            <tr>
                <td>Row1 Column1</td><td>Row1 Column2</td><td>Row1 Column3</td><td>Row1 Column4</td><td>Row1 Column5</td>
            </tr>
            <tr>
                <td>Row2 Column1</td><td>Row2 Column2</td><td>Row2 Column3</td>    <td>Row2 Column4</td><td>Row2 Column5</td>
            </tr>
            <tr>
                <td>Row3 Column1</td><td>Row3 Column2</td><td>Row3 Column3</td><td>Row3 Column4</td><td>Row3 Column5</td>
            </tr>
            <tr>
                <td>Row4 Column1</td><td>Row4 Column2</td><td>Row4 Column3</td><td>Row4 Column4</td><td>Row4 Column5</td>
            </tr>
            <tr>
                <td>Row5 Column1</td><td>Row5 Column2</td><td>Row5 Column3</td><td>Row5 Column4</td><td>Row5 Column5</td>
            </tr>
        </tbody>
    </table>
</div>

<script>
    $("#compare-tbl-2 td").hover(function() {
            $(this).parents('table').find('td:nth-child(' + ($(this).index() + 1) + ')').
                  add($(this).parent()).addClass('compare-hover');
      },
      function() {
            $(this).parents('table').find('td:nth-child(' + ($(this).index() + 1) + ')').
                  add($(this).parent()).removeClass('compare-hover');
      });
</script>
  • 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-18T05:52:14+00:00Added an answer on June 18, 2026 at 5:52 am

    Try replacing your script with this:

    $("#compare-tbl-2 td").hover(function() {
    $(this).closest('tr').addClass('compare-hover');
    var idx = $(this).closest('tr')[0].sectionRowIndex + 1;
    
    $('#compare-tbl-1').find('tr:nth-child(' + idx + ')').addClass('compare-hover');
      },
      function() {
          $(this).closest('tr').removeClass('compare-hover');
          $('#compare-tbl-1').find('tr').removeClass('compare-hover');
      });
    

    jsFiddle

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

Sidebar

Related Questions

I have a treeview that renders as tables. The html would be something like:
I would like to have my accounts shown like below (In a List) <div
Possible Duplicate: Vertically align div (no tables) I have a div and I would
I would want to simulate the behavior of a table with div. I have
I have 2 tables in separate <div> 's. One is the header and the
I have replaced a table containing four tables (in a grid) with a div-table
I have an HTML table like: <div> <table border=1> <thead> <tr class=example> <th> <span
I would like to options for making tables in my css. One with a
I have a <div contenteditable=true> that I am trying to use to get text
Right now I have a webpage set up to be exactly the size of

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.