Skip to content

Commit

Permalink
Add nth-child feature-detect
Browse files Browse the repository at this point in the history
  • Loading branch information
emilchristensen committed Sep 6, 2012
1 parent 9f7e7dd commit d1e9add
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions feature-detects/css-nthchild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// nth-child pseudo selector
Modernizr.addTest('nthchild', function(){

return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) {
var elems = elem.getElementsByTagName("div"),
test = true;
for (i=0; i<5; i++) {
test = test && elems[i].offsetWidth == i%2+1;
}
return test;
}, 5);

});

0 comments on commit d1e9add

Please sign in to comment.