counter-increment-000.xht (1401B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: dynamic changes to 'counter-increment'</title> 5 <link rel="author" title="L. David Baron" href="https://dbaron.org/"/> 6 <link rel="help" href="http://www.w3.org/TR/CSS21/generate.html#counters"/> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/generate.html#propdef-content"/> 8 <link rel="help" href="http://www.w3.org/TR/CSS21/syndata.html#counter"/> 9 <meta name="flags" content="dom"/> 10 <meta http-equiv="Content-Script-Type" content="text/javascript"/> 11 <style type="text/css"> 12 13 body { white-space: nowrap; } 14 15 16 #test, .reset { counter-reset: c; } 17 .increment:before { content: counters(c, ".") "-"; } 18 .increment { counter-increment: c; } 19 20 </style> 21 <script type="text/javascript"> 22 23 function run() { 24 var t = document.getElementById("test"); 25 var s = document.createElement("span"); 26 s.setAttribute("class", "increment"); 27 s.appendChild(document.createTextNode("new-")); 28 t.insertBefore(s, t.childNodes.item(1)); 29 } 30 31 </script> 32 </head> 33 <body onload="setTimeout('run()', 0)"> 34 35 <p>The following two lines should be the same:</p> 36 37 <div id="test"><span class="increment"></span><span class="increment"></span><span class="increment"></span></div> 38 39 <div id="reference">1-2-new-3-4-</div> 40 41 </body> 42 </html>