I want to use jQuery 1.3.2 in an html file and create a dynamic table. For this, I create the first row, then create a for loop running 10 times and in each iteration, I select the last row of the table and use after() to add a new row after it. This new row contains the value of the counter of my for loop.
code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document</title>
<script type="text/javascript" src="../jquery-1.3.2.js"></script>
<script type="text/javascript">
$("document").ready(function() {
for (var i = 0; i < 11; i += 1) {
var newItem = $("<tr><td>"i"</td></tr>");
$("#table1 tr:last").after(newItem.html());
}
});
</script>
</head>
<body>
<table id="table1">
<tr>
<td>row 1 col 1</td>
</tr>
</table>
</body>
</html>
The problem is, only the first row that was created in <table></table> is displayed. Please help out.