OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body style="font-family: ahem; -webkit-font-smoothing: none;"> | 3 <body style="font-family: ahem; -webkit-font-smoothing: none;"> |
4 <style> | 4 <style> |
5 div.table { display: table; } | 5 div.table { display: table; } |
6 div.section { display: table-row-group; } | 6 div.section { display: table-row-group; } |
| 7 div.test { background-color: green; width: 50px; height: 50px; } |
7 </style> | 8 </style> |
8 | 9 |
9 <div class="table" id="table-1"> | 10 <div class="table" id="table-1"> |
10 <div class="section" id="tbody-1"> | 11 <div class="section" id="tbody-1"> |
11 </div> | 12 </div> |
12 <div class="section" id="tbody-2"> | 13 <div class="section" id="tbody-2"> |
13 </div> | 14 </div> |
14 </div> | 15 </div> |
15 | 16 |
16 <script> | 17 <script> |
17 function createSpan() | 18 function createDiv() |
18 { | 19 { |
19 var spanElement = document.createElement("span"); | 20 var divElement = document.createElement("div"); |
20 spanElement.appendChild(document.createTextNode("Some text.")); | 21 divElement.setAttribute("class", "test"); |
21 return spanElement; | 22 return divElement; |
22 } | 23 } |
23 | 24 |
24 function insertSpan(tableID, beforeID) | 25 function insertDiv(tableID, beforeID) |
25 { | 26 { |
26 var table = document.getElementById(tableID); | 27 var table = document.getElementById(tableID); |
27 var before = document.getElementById(beforeID); | 28 var before = document.getElementById(beforeID); |
28 table.insertBefore(createSpan(), before); | 29 table.insertBefore(createDiv(), before); |
29 } | 30 } |
30 | 31 |
31 document.body.offsetTop; | 32 document.body.offsetTop; |
32 | 33 |
33 insertSpan("table-1", "tbody-2"); | 34 insertDiv("table-1", "tbody-2"); |
34 </script> | 35 </script> |
35 </body> | 36 </body> |
36 </html> | 37 </html> |
OLD | NEW |