PDA

View Full Version : nth-child with JS



d-machine
09-17-2013, 08:44 AM
Hi,

I'm using nth-child in the following way, which is not supported on IE 8.
How can I write a javascript command that will perform the same operation?



table.tbl1 tr:nth-child(2n+2) td {
background-color:#CEC5C1;
}
table.tbl1 tr:nth-child(2n+1) td {
background-color:#F6F4F3;
}
ul#cat li:nth-child(4n+4) {
margin:0 0 20px 9px;
}

Beverleyh
09-17-2013, 11:03 AM
This may be of interest to you: http://selectivizr.com/

And this snippet with jQuery: http://ryan.sadwick.com/nth-child/

This CSS-only workaround also looks interesting: http://abouthalf.com/development/poor-mans-nth-child-selector-for-ie-7-and-8/