1

I am wondering if such a javascript library exists to do the following:

  1. Look at what CSS stylesheets are included on the page
  2. Look at the browser to see if it supports selector XYZ on the stylesheet.
  3. If not, use jquery to apply said style manually.

I am wanting such a library because throughout my site I am using tr:nth-child(odd) td to apply alternating row colors on tables. I can use jquery to apply these colors, but it would be nice if I could just include a library instead of duplicating my CSS in javascript everywhere.

4

2 回答 2

3

You should look into using Selectivizr.

Selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8. Simply include the script in your pages and selectivizr will do the rest.

Using this, you will have support for the nth-child selector, amongst various other pseudo/attribute selectors in IE6 through to IE8.

If you're already using a JavaScript library such as jQuery or Mootools, it's as simple as including the script. Here is a tutorial for reference sake.

于 2013-06-19T13:02:23.263 回答
1

take a look at modernizer http://modernizr.com/

I think its what you are looking for.

于 2013-06-19T13:00:25.813 回答