This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Generalized table striping using JQuery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Generalized table striping using JQuery" Watch "Generalized table striping using JQuery" New topic
Author

Generalized table striping using JQuery

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Is there a way to generalize this kind of JQuery trick:



to add a class to, say, every third or fourth row of a table, rather than every second row?


[Jess in Action][AskingGoodQuestions]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63195
    
  69

Have you considered the nth-child:Xn+Y form of selector?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Thanks, Bear, that works perfectly -- I had no idea such a thing was in there.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63195
    
  69

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15385
    
    6
With CSS3 enabled browsers, you do not even need to use jQuery. That would be a big performance gain.



Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63195
    
  69

Unfortunately, not everyone is using modern browsers. Microsoft keeps threatening to instill auto-upgrades a la Chrome and Firefox, but it hasn't happened yet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generalized table striping using JQuery
 
It's not a secret anymore!