File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 24183
    
  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: 60997
    
  65

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: 24183
    
  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: 60997
    
  65

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    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: 60997
    
  65

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.
 
 
subject: Generalized table striping using JQuery