JS删除练习

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        #tbList {
            margin: 10px auto;
            border-collapse: collapse; /*是否合并为单一边框*/
        }
    </style>
    <script type="text/javascript">
        var arr = [{
            "title": "一个C#问题", "name": "张三", "date": "2014-05-24"
        },
        {
            "title": "一个C#问题", "name": "张三", "date": "2014-05-24"
        }, {
            "title": "一个C#问题", "name": "张三", "date": "2014-05-24"
        }, {
            "title": "一个C#问题", "name": "张三", "date": "2014-05-24"
        }, {
            "title": "一个C#问题", "name": "张三", "date": "2014-05-24"
        }
        ];
        window.onload = function () {
            loadData();
            //方法不能写在这里面
        }
        function loadData() {
            var tb = document.getElementById("tbList");

            var trNew = document.createElement("tr");
            for (var j = 0; j < arr[i].length; j++) {
                var td1 = document.createElement("td");
                td1.innerHTML = arr[i].title;
                trNew.appendChild(td1);
                tb.appendChild(trNew);
            }
        }
    </script>
</head>
<body>
    <table id="tbList" border="1">
        <tr>
            <td>序号</td>
            <td>标题</td>
            <td>发件人</td>
            <td>发件时间</td>

        </tr>
    </table>
</body>
</html>

  

posted @ 2014-06-13 23:44  编程猴子  阅读(198)  评论(0编辑  收藏  举报