css3-modsel-d4.xml (1102B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Dynamic updating of :first-child and :last-child</title> 5 <style type="text/css"><![CDATA[ 6 #two:first-child { background: red; } 7 #three:last-child { background: lime; } 8 ]]></style> 9 <link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch"/> 10 <link rel="help" href="https://www.w3.org/TR/css3-selectors/#selectors"/> <!-- bogus link to make sure it gets found --> 11 <meta name="flags" content=" dom" /> 12 </head> 13 <body> 14 15 <div> 16 17 <script type="text/javascript"> 18 <![CDATA[ 19 20 function test() { 21 el2 = document.getElementById('two'); 22 el3 = document.getElementById('three'); 23 el2.parentNode.insertBefore(el3.nextSibling, el2); 24 } 25 26 window.setTimeout("test()", 100); 27 ]]> 28 </script> 29 30 <div><p id="two">This line should be unstyled. (2)</p><p id="three">This line should have a green background. (3)</p><p>This line should be unstyled. (4 moving to 1)</p></div> 31 32 </div> 33 34 </body> 35 </html>