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)

更多内容请见原文,文章转载自:https://blog.csdn.net/qq_43650923/article/details/103050484

posted @ 2021-12-13 19:10  malala  阅读(28)  评论(0编辑  收藏  举报