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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:20:40+00:00 2026-06-13T13:20:40+00:00

I have taken the Chris Coyier table row and col highlight code and added

  • 0

I have taken the Chris Coyier table row and col highlight code and added zebra striping. I can get the row to highlight but the col stops highlighting when zebra stripes are enabled.

If you uncomment the 1st 2 lines of jQuery to show zebra striping you will see the problem I’ve outlined above.

Not entirely sure why these are conflicting.

Any help appreciated.

Sorry about ALL the code being here but it seems I can’t use jsFiddle to show you, ya know, that really helpful service to show you code working so you can edit and fiddle with it.

CSS

table           {width:100%; border-collapse:collapse;}

    th          {background:#95bce2; color:white; font-weight:bold;}
    td, th      {padding:6px; border:1px solid #95bce2; text-align:left;}

.even           {background-color:#ecf6fc;}
.odd            {background-color:white;}

.hover          {background-color:#ccc!important;}
.focus          {background-color:#6ab9d0!important; color:white;}​

JQuery

/* If I uncomment these lines the colgroup highlight doesn't work */ 
//$('tr:odd').addClass('odd')
//$('tr:even').addClass('even')


$('.table1').delegate('td','mouseover mouseleave', function(e)
{
    if (e.type == 'mouseover')
    {            
        $(this).addClass('focus');
        $(this).parent().addClass('hover');
        $("colgroup").eq($(this).index()).addClass('hover');
    }
    else
    {
        $(this).removeClass('focus');
        $(this).parent().removeClass('hover');
        $('colgroup').eq($(this).index()).removeClass('hover');
    }
});

HTML

<table class="table1">
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
        <colgroup></colgroup>
    <thead>
        <tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Job Title</th>
            <th>Favorite Color</th>
            <th>Wars or Trek?</th>
            <th>Porn Name</th>
            <th>Date of Birth</th>
            <th>Dream Vacation City</th>
            <th>GPA</th>
            <th>Arbitrary Data</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>James</td>
            <td>Matman</td>
            <td>Chief Sandwich Eater</td>
            <td>Lettuce Green</td>
            <td>Trek</td>
            <td>Digby Green</td>
            <td>January 13, 1979</td>
            <td>Gotham City</td>
            <td>3.1</td>
            <td>RBX-12</td>
        </tr>
        <tr>
          <td>The</td>
          <td>Tick</td>
          <td>Crimefighter Sorta</td>
          <td>Blue</td>
          <td>Wars</td>
          <td>John Smith</td>
          <td>July 19, 1968</td>
          <td>Athens</td>
          <td>N/A</td>
          <td>Edlund, Ben (July 1996).</td>
        </tr>
        <tr>
          <td>Jokey</td>
          <td>Smurf</td>
          <td>Giving Exploding Presents</td>
          <td>Smurflow</td>
          <td>Smurf</td>
          <td>Smurflane Smurfmutt</td>
          <td>Smurfuary Smurfteenth, 1945</td>
          <td>New Smurf City</td>
          <td>4.Smurf</td>
          <td>One</td>
        </tr>
        <tr>
          <td>Cindy</td>
          <td>Beyler</td>
          <td>Sales Representative</td>
          <td>Red</td>
          <td>Wars</td>
          <td>Lori Quivey</td>
          <td>July 5, 1956</td>
          <td>Paris</td>
          <td>3.4</td>
          <td>3451</td>
        </tr>
        <tr>
          <td>Captain</td>
          <td>Cool</td>
          <td>Tree Crusher</td>
          <td>Blue</td>
          <td>Wars</td>
          <td>Steve 42nd</td>
          <td>December 13, 1982</td>
          <td>Las Vegas</td>
          <td>1.9</td>
          <td>Under the couch</td>
        </tr>
    </tbody>
</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-06-13T13:20:41+00:00Added an answer on June 13, 2026 at 1:20 pm

    why don’t you use the :hover pseudo-classes for the selector? you don’t need to (and you shouldn’t) do it using javascript, if you use pure css you cover also browsers even with js disabled

    for the even/odd classes, just put the classes on the php/html file or user css rules (if you don’t care about old browsers) http://www.w3.org/Style/Examples/007/evenodd

    table           {width:100%; border-collapse:collapse;}
    
    th          {background:#95bce2; color:white; font-weight:bold;}
    td, th      {padding:6px; border:1px solid #95bce2; text-align:left;}
    
    tr:nth-child(even)           {background-color:#ecf6fc;}
    tr:nth-child(odd)           {background-color:white;}
    
    tr:hover, td.hover          {background-color:#ccc!important;}
    td:hover          {background-color:#6ab9d0!important; color:white;}
    

    The colgroup tag is deprecated so you shouldn’t use it, you do need js fot that

    $('.table1 td').hover(
      function(){
        $('.table1 td:nth-child('+($(this).index()+1)+')').addClass('hover');
      },
      function(){
        $('.table1 td:nth-child('+($(this).index()+1)+')').removeClass('hover');
      });
    

    check this fiddle http://jsfiddle.net/YDLDm/6/

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

Sidebar

Related Questions

I have taken this little snippet straight out of some code I'm working on:
I have taken the backup of mysql database but when I am trying to
I have taken a look at GTK+3 and I like it. But unfortunately compiling
I have taken a manifest from one of the answers posted here in SO
I have taken over a project that was build from suggestions in this Dan
I have taken following array; to fill-up gallery: private Integer[] mImageIds = { R.drawable.one,
I have taken a imageview in applicationDidFinishLaunching as shown below. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
i have taken the default asp.net mvc template and customized to work for me.
I have taken three textboxes over aspx page. A JavaScript function is associated with
I have taken char data into database into array. now i want to convert

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.