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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:10:55+00:00 2026-05-23T13:10:55+00:00

I am using JQuery Templates to render a number of tables from a JSON

  • 0

I am using JQuery Templates to render a number of tables from a JSON data source.

Once the tables are rendered, I am attaching a Jquery “hover” event handler (via table CSS class) to highlight table columns.

The hover event works, but affects all rendered tables of the same CSS class – so If I hover over column 2 of table 1, column 2 of ALL my tables are also highlighted.

I would much prefer not to attach an individual ID for each table – nothing else would need it.

I have done some Googling and the use of JQuery “closest()” in the hover event handler seems promising, but I cannot figure out the correct usage 🙁

Any help would be very much appreciated.

$(document).ready(function() {
    drawRows();
    setColumnHover();
});

function drawRows() {
    var jsonData = jQuery.parseJSON(getJsonString());
    $("#tableTemplate").tmpl(jsonData).appendTo("#funnelBody");
    }

function setColumnHover() {
   /* Ref: http://www.local-guru.net/blog/2010/10/29/table-column-highlighting-with-jquery */
    $(".statsTable td").hover(
        function() {
            var idx = $(this).parent().children('td,th').index($(this)) + 1;
            if (idx > 1) {
                $('td:nth-child(' + idx + ')').addClass('hover');
                $('th:nth-child(' + idx + ')').addClass('hover');
            }
        }
        ,
        function() {
            var idx = $(this).parent().children('td,th').index($(this)) + 1;
            if (idx > 1) {
                $('td:nth-child(' + idx + ')').removeClass('hover');
                $('th:nth-child(' + idx + ')').removeClass('hover');
            }
        }
    );
}

///////////// Rendered HTML
<table class="statsTable">
    <tr>
        <td>...</td>
        <td>...</td>
    </tr>
    <tr>
        <td>...</td>
        <td>...</td>
    </tr>
</table>
  • 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-23T13:10:56+00:00Added an answer on May 23, 2026 at 1:10 pm

    Just need to focus on assigning the class by “this” instead of by name. The following should do the trick.

    $(".statsTable td").hover(
        function() {     
            $(this).addClass('hover');
        },
        function() {
            $(this).removeClass('hover');
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rebecca Murphy talks about using jQuery templates. The JSON that Rebecca uses looks like:
I'm just starting to wean myself from ASP.NET UpdatePanels. I'm using jQuery and jTemplates
Using jQuery, how do you bind a click event to a table cell (below,
When using jQuery 's ajax method to submit form data, what is the best
I am using Rails and jquery with RJS templates to perform various AJAX requests.
I'm using jQuery Templates for a bunch of a site I'm working on, and
The Good: We send a JSON array of nested objects using JQuery and .ajax().
I'm trying to interrogate a string value using JQuery.tmpl() from within an {{if}} block
I'm using jquery templates to populate a table. I'm wondering if it's possible to
I am using jquery templates on both the server-side and client-side. I'm using 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.