Created
November 2, 2011 10:17
-
-
Save meyertee/1333330 to your computer and use it in GitHub Desktop.
Modernizr Test 'nthchildn'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test for nth-child(...n) support | |
Modernizr.testStyles(" #modernizr div:nth-child(3n){width:10px;} ", function(elem, rule){ | |
var bool = false, divs = elem.getElementsByTagName("div"); | |
if (divs.length == 7){ | |
var test = window.getComputedStyle ? function(i){ | |
return getComputedStyle(divs[i], null)["width"] == "10px"; | |
} : function(i){ | |
return divs[i].currentStyle["width"] == "10px"; | |
}; | |
bool = !test(0) && !test(1) && test(2) && !test(3) && !test(4) && test(5) && !test(6); | |
} | |
Modernizr.addTest("nthchildn", bool); | |
}, 7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sxfdsff