JS动态创建table

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
    <style type="text/css">
        table td{
            border:1px solid blue;
        }
    </style>
    <script type="text/javascript">
        var dicList = {
            '罗分明': 'http://www.luofenming.com',
            '95网络': 'http://www.995w.com',
            '新兴网络': 'http://www.newxing.com'
        };
        window.onload = function () {
            document.getElementById('btn1').onclick = function () {
                var tableObject = document.createElement('table');
                for (var key in dicList) {
                    var trObject = document.createElement('tr');
                    var tdObject1 = document.createElement('td');
                    tdObject1.innerHTML = key;
                    var tdObject2 = document.createElement('td');
                    tdObject2.innerHTML = dicList[key];
                    trObject.appendChild(tdObject1);
                    trObject.appendChild(tdObject2);
                    tableObject.appendChild(trObject);
                }
                document.body.appendChild(tableObject);
            }
           
        }
    </script>
</head>
<body>
    <input type="button" id="btn1" value="按扭" />
</body>
</html>

评论