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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:21:02+00:00 2026-05-26T23:21:02+00:00

I typically zebra stripe table rows for odd / even like so and it

  • 0

I typically zebra stripe table rows for odd / even like so and it works well:

$("table tbody tr:visible:even",this).addClass("even"); 
$("table tbody tr:visible:odd",this).addClass("odd");

However, I have a data table where there are three consecutive rows for 1 set of data. The next three consecutive rows would be for the next set of data. So ideally I’d like to take the first three rows and add a class of even and then the next three rows after that to have a class of odd.

  • 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-26T23:21:02+00:00Added an answer on May 26, 2026 at 11:21 pm

    Here’s something I whipped up on jsfiddle:

    $("tr:nth-child(6n)").addClass("odd")
        .prev().addClass("odd")
        .prev().addClass("odd");
    

    What this does is select every 6th tr element, set its class to odd, and the same to the previous two tr elements, thus giving you the result of 3 “grouped” rows.

    More about the nth-child() selector here, and more about the prev() function here.

    You could change the code to this to add an even class to the three rows preceding the ones with the odd classname:

    $("tr:nth-child(6n)").addClass("odd")
        .prev().addClass("odd")
        .prev().addClass("odd")
        .prev().addClass("even")
        .prev().addClass("even")
        .prev().addClass("even");
    

    That looks like this.

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

Sidebar

Related Questions

Typically you will find STL code like this: for (SomeClass::SomeContainer::iterator Iter = m_SomeMemberContainerVar.begin(); Iter
typically when you refer to an object you would use a selector like this
typically definition of property/column looks like this: <property name=DocumentSummary column=DocumentSummary length=100 type=String> <column name=DocumentSummary
Typically I have to write layout code like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical
I typically write something like this: class Person < ActiveRecord::Base attr_accessible :first_name, :last_name def
Typically, I would call another class method like this: MyClass *class = [[MyClass alloc]
Typically when creating an action from something like a button you have this [button
typically the code is something like: <html> <head> <style type=text/css> body { font-size:12pt; font-family:
Typically I do something like: q = Queue() p = Process(target=f, args=(q,)) p.start() Is
Typically one may simply call optparse's method parse_args without any arguments. If, however, one

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.