本帖最后由 丁官林 于 2012-4-16 11:58 编辑
这段始终单击按钮运行不出来,我不知道错在了哪里?哪位大侠帮帮忙,谢谢!
<head>
<title></title>
<script type="text/javascript">
function LoadData(){
var data = {"百度":"http://www.baidu.com","传智":"http://www.itcast.cn"};
var tableLinks = document.getElementById("tableLinks");
for (var key in data) {
var tr = document.createElement("tr");
var value=data[key];
var td1 = document.createElement("td");
td1.innerText = key;
tr.appendChild(td1);
var td2 = document.createElement("td");
td2.innerHTML = "<a href='" + value + "'>" + value + "</a>";
tr.appendChild(td2);
tableLinks.appendChild(tr);
}
}
</script>
</head>
<body>
<table id="tableLinks" ></table>
<input type="button" value="加载" />
</body> |