Jquery Dynamic table create?
html, jquery
Solution
Try my answer
$(function () {
$("#addProduct").click(function () {
var table = $('<table></table>').addClass('foo');
for (var i = 0; i < 10; i++) {
row = $('<tr></tr>');
for (var j = 0; j < 10; j++) {
var rowData = $('<td></td>').addClass('bar').text('result ' + j);
row.append(rowData);
}
table.append(row);
}
if ($('table').length) {
$("#someContainer tr:first").after(row);
}
else {
$('#someContainer').append(table);
}
});
});
Problem
How to create Dynamic table using JQuery I created with .append but problem is when i am clicking on again so create anther table but i want add in to a same table so how can i do that please help me. ``` $(function () { $("#addProduct").click(function () { var table = $('<table></table>').addClass('foo'); for (i = 0; i < 10; i++) { var row = $('<tr></tr>'); for (i = 0; i < 10; i++) { var row1 = $('<td></td>').addClass('bar').text('result ' + i); table.append(row); row.append(row1); } } $('#someContainer').append(table); }); }); ``` This is HTML ``` <button id="addProduct">Add Product</button> <div id="someContainer"></div> ```