如何给动态创建的表格添加表格线
<script type="text/javascript">
function loadData() {
var data = {"百度":"http://www.baidu.com","新浪":"http://www.sina.com","CSDN":"http://www.csdn.net"};
var tableLinks = document.getElementById("tableLinks");
for(var key in data){
var value = data[key];
var tr = document.createElement("tr");
var td1 = document.createElement("td");
td1.innerText = key;
tr.appendChild(td1);
var td2 = document.createElement("td");
td2.innerText = value;
tr.appendChild(td2);
tableLinks.appendChild(tr);
//为表格动态添加样式
//tableLinks.style.border="2px solid #0000FF";
}
}
</script>
<!--网页内容-->
<body>
<table id="tableLinks"></table>
<input type="button" value="加载表数据" onclick="loadData()" />
</body>
------解决方案--------------------
<table id="tableLinks" border="1"></table>