<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function LoadDate()
{
var date ={"百度":"http:\\www.baidu.com","腾讯":"http://www.qq.com"};
var tableLinks = document.getElementById("tableLinks");
var tr = document.createElement("tr");
for(var key in date)
{
var td = document.createElement("td");
td.innerHTML=(key);
tr.appendChild(td);
var td2 = document.createElement("td");
td2.innerHTML=("<a href='"+date[key]+"'>进入</a>");
tr.appendChild(td2);
tableLinks.appendChild(tr);
}
}
</script>
</head>
<body>
<table id="tableLinks"></table>
<input type="button" value="添加表数据" onclick="LoadDate()"/>
</body>
</html>
用这些代码产生:
如何使它显示为:
百度 进入
腾讯 进入
?????????????????????
<script type="text/javascript">
var date ={"百度":"http:\\www.baidu.com","腾讯":"http://www.qq.com"};
function LoadDate()
{
var tableLinks = document.getElementById("tableLinks");
for(var key in date)
{
var tr = document.createElement("tr");
tr.innerHTML="<br/>";
var td = document.createElement("td");
td.innerHTML=(key);
tr.appendChild(td);
var td2 = document.createElement("td");
td2.innerHTML=("<a href='"+date[key]+"'>进入</a>");
tr.appendChild(td2);
tableLinks.appendChild(tr);
}
}
</script>