<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>
Hello everyone! Thanks for reviewing my second post. I’m a jquery newbie and looking for figure out why I can’t build a row and cell dynamically? Any help is appreciated!
As said Frédéric Hamidi, you don’t open and close tag in jQuery, you simply add a tag inside another, and use it as simple variable to do some stuff with it.
Then your “each” parsing should look like this :