<html><head>
<link type="text/css" rel="stylesheet" href="file:///C:/Users/Documents/style.css" />
<script type="text/javascript" src="file:///C:/Users/Documents/jquery-1.7.1.js"></script>
<script type="text/javascript" src="file:///C:/Users/Documents/jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function() {
load();
});
var map1 = { "iDate":"test_value1", "iName":"test_value2" , "iFile":"test_value3" };
var map2 = { "iDate":"nexttest_value1", "iName":"nexttest_value2", "iFile":"nexttest_value3" };
var list = new Array(map1, map2);
list[0] = map1;
list[1] = map2;
function load() {
var beginTD = $("<td><div class='scroll-pane horizontal-only' style='vertical-align: top'>");
var endTD = $("</div></td>");
jQuery.each(list, function(index, map) {
$("#hpTable > tbody:last").append($("<tr>"));
jQuery.each(map, function(key, value) {
var pTag = $("<p id='" + key + "'>" + value + "</p>");
$("#hpTable td:last").append(beginTD, pTag, endTD);
});
$("#hpTable").append($("</tr>"));
});
};
</script>
</head>
<body>
<br>
<table id="hpTable" cellpadding="5" width="100%" style="table-layout:fixed" class="tablesorter">
<thead><tr>
<th width="9%">Date</th>
<th width="9%">Name</th>
<th>File</th>
</tr>
</thead>
<tbody></tbody>
</table>
</body
</html>
大家好!感謝您審查我的第二篇文章。我是一個jquery新手,並尋找找出爲什麼我不能動態地建立一個行和單元格?任何幫助表示讚賞!建立一個動態的行和單元格使用jquery
你不能使用append()向DOM添加元素片段(例如,在一次調用中加入'
喜弗雷德裏克,我想動態創建一個行循環通過地圖的列表(字符串,字符串)。 – sasims 2012-03-23 16:30:37