1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Strict//EN">
4 <title>CSS Test: :nth-child(n) selector
</title>
5 <style type=
"text/css">
6 div
div:nth-child
(n
) { color: green
; }
10 window
.testRunner
.dumpAsText()
14 <p>The test passes if all DIVs are green.
</p>
19 <div id=
"testresult" style=
"color: blue">Running
</div>
20 <script type=
"text/javascript">
21 function ArrayContains(array
, value
, ci
)
23 ci
= ci
== true ? true : false;
24 for (var i
= 0; i
< array
.length
; i
++)
26 if (ci
&& array
[i
].toLowerCase() == value
.toLowerCase())
30 else if (array
[i
] == value
)
42 var greenValues
= new Array("green", "#008000", "rgb(0, 128, 0)");
44 var elem
= document
.getElementById("test");
45 var val
= getComputedStyle(elem
.children
[0], null).getPropertyValue("color");
46 if (ArrayContains(greenValues
, val
, false))
48 document
.getElementById("testresult").innerHTML
= "Pass";
52 document
.getElementById("testresult").innerHTML
= "Fail";