javascript當中CreateTRTD2的用法
例 2.4(CreateTRTD2IEFF.html)
<style>
#TableOne {undefined
position: absolute;
top: 200;
left: 100;
}
</style>
<script>
function buildTable() {undefined
/*馬克-to-win:雖然body只有一個,document.getElementsByTagName("body")會返回一個nodelist,所以必須
取第0個。*/
docBody = document.getElementsByTagName("body").item(0)
bodyQixy = document.body;
alert("docBody===bodyQixy is " + (docBody === bodyQixy));
myTable = document.createElement("TABLE")
myTable.id = "TableOne"
myTable.border = 5
myTableBody = document.createElement("TBODY")
for (i = 0; i < 3; i++) {undefined
row = document.createElement("TR")
for (j = 0; j < 3; j++) {undefined
cell = document.createElement("TD")
cell.style.color = "red"
cell.style.background = "#00ffff"
cell.width = 50
cell.height = 20
textVal = "Cell" + i + "_" + j
textNode = document.createTextNode(textVal)
cell.appendChild(textNode)
row.appendChild(cell)
更多內容請見原文,文章轉載自: