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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:01:37+00:00 2026-06-14T17:01:37+00:00

I’m using DataTables and have hacked together this somewhat embarrassing Javascript to allow row

  • 0

I’m using DataTables and have hacked together this somewhat embarrassing Javascript to allow row and column highlighting. It’s based on the example on this page ( http://datatables.net/release-datatables/examples/api/highlight.html ).

Here’s the relevant parts of the dataTable configuration:

$(document).ready(function() {
    $('#franchise_history').dataTable( {
        "bPaginate": false,
        "bLengthChange": false,
        "bFilter": true,
        "bSort": false,
        "bInfo": true,
        "bAutoWidth": true,
        "sScrollY": "100%",
        "sScrollX": "100%",
        "asStripeClasses": [],
        "fnInitComplete": function (conf, json) {
            var tbl = $($.fn.dataTable.fnTables(true)).dataTable();
            $('td', tbl.fnGetNodes()).hover( function() {
                var iCol = $('td').index(this) % some_constant;
                var nTrs = tbl.fnGetNodes();
                $('td:nth-child('+(iCol+1)+')', nTrs).addClass('highlighted');
            }, function() {
                $('td.highlighted', tbl.fnGetNodes()).removeClass('highlighted');
            });
      }
} );
} );

some_constant is inserted by the templating code on the server. It’s the number of columns. Here’s the DataTables debug output: http://debug.datatables.net/oceqix and here’s the page it was derived from http://pro-football-history.com/franchise/37/pittsburgh-steelers-coaches

As you can see hovering over columns doesn’t properly hilight the right column. What’s going wrong here? I’m very clueless when it comes to Javascript and I’m basically at the limit of my JavaScript debugging ability here. I would appreciate it if any answers also explained the debugging process they went through to find it.

  • 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-14T17:01:38+00:00Added an answer on June 14, 2026 at 5:01 pm

    Looks like the problem in the following line

     var iCol = $('td').index(this) % some_constant;
    

    Changing to the below should solve your problem:

    var iCol = $('td', this.parentNode).index(this) % some_constant;
    

    The issue is that $('td') gives you all TDs in the document but you need to get them only for the current row.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I am reading a book about Javascript and jQuery and using one of the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to

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.