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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:04:30+00:00 2026-05-19T05:04:30+00:00

A page contains two tables. First table is loaded together with the whole page

  • 0

A page contains two tables. First table is loaded together with the whole page and the second table is loaded afterwards with the help of ajax.
Both tables contain links in each their row.
After clicking a link the corresponding table row (where link is) should be highlighted.

With the first table there are no problem. The following works ok:

$(document).ready(function () {
        $('#firstTable tr a').click(function (event) {               
            $('#firstTable tr').css("background-color", "white");
            $(this).closest('tr').css("background-color", "silver");
        });
    });

But there are problems with the second table. I try to use .live() method but with no success, it doesn’t react on clicks:

function onLoad() {
              $('#secondTable tr a').live('click', function () {
                  highlChooseRow();
              });
          }

          function highlChooseRow() {
              $('#secondTable tr').css("background-color", "white");
              $(this).closest('tr').css("background-color", "silver");
          }

What am I doing wrong?

  • 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-05-19T05:04:31+00:00Added an answer on May 19, 2026 at 5:04 am

    How about

    $(document).ready(function () {
        $('#firstTable tr a, #secondTable tr a').live('click', function (event) {               
            $(this).parent('table').find('tr').css("background-color", "white");
            $(this).closest('tr').css("background-color", "silver");
        });
    });
    

    should work without any problems. for cleanup you could also define some class ‘.higlightable-table’ or something like that and use $('.hightlightable-table a').live …

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

Sidebar

Related Questions

I have 3 tables on a page. Each of them contain two table rows.
I have two tables, one contains the page/heading number and the heading text, the
I have an ASP.NET page that contains two div's. Both have search fields and
Currently I have two pages: The first page contains an input form, and the
lets say i have two pages links.html & contents.php ... first page contains only
I have 2 div tag. The first contains a table. The second contains some
I have two tables on my page and they appear side-by-side. The first one
I have two tables. The first one contains all the item informations and the
I have created a table with two columns. The first column contains the hyperlinks,
I have two tables: groups and group_members . The groups table contains all the

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.