Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 28th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 85  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Test for nth-child(...n) support
  2. Modernizr.testStyles(" #modernizr div:nth-child(3n){width:10px;} ", function(elem, rule){
  3.         var bool = false, divs = elem.getElementsByTagName("div");
  4.         if (divs.length == 7){
  5.                 var test = window.getComputedStyle ? function(i){
  6.                         return getComputedStyle(divs[i], null)["width"] == "10px";
  7.                 } : function(i){
  8.                         return divs[i].currentStyle["width"] == "10px";
  9.                 };
  10.                 bool = !test(0) && !test(1) && test(2) && !test(3) && !test(4) && test(5) && !test(6);
  11.         }
  12.         Modernizr.addTest("nthchildn", bool);
  13. }, 7);