my dog learned polymorphism*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60785
    
  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: 60785
    
  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: 60785
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generalized table striping using JQuery
 
Similar Threads
Change the background color of a row in a table upon mouse click
Trying out jquery, but things are not working out
JQuery vs Dojo
jQuery in Action - is jQuery an abstraction
Prototype tableID in function