Hay muchas maneras diferentes que usted puede ir con esto. Una forma es hacer algo como esto:
// $(document).ready() makes sure that nothing happens until the page
// is fully loaded. It's important because the div may not have loaded
// yet if you put code outside of this
$(document).ready(function() {
$("#div1").append(
"<table><tr><td>My column 1, row 1</td>" +
"<td>My column 2, row 2</td></tr>" +
"<tr><td>My column 1, row 2</td>" +
"<td>My column 2, row 2</td></tr></table>");
});
Esto hará que la tabla completa en su div, se analiza como HTML. De otra manera, si desea agregar cada fila por separado, sería:
$(document).ready(function() {
$("#div1").append("<table id=\"my_table1\"></table>");
$("#my_table1").append("<tr><td>Row 1</td></tr>");
... insert more rows here ...
$("#my_table1").append("<tr><td>Row ...</td></tr>");
});
Es importante entender que .append()
pondrá el HTML o texto que introduzca dentro de cualquier elemento que haya seleccionado mediante el selector de signo de dólar ($("selector text")
)