0

Im using jQuery to generate a table:

var container = jQuery(".container");
container.append("<table class='table table-striped'>");
container.append("<tr><td>1</td><td>A</td></tr>");
container.append("<tr><td>2</td><td>B</td></tr>");
container.append("<tr><td>3</td><td>C</td></tr>");
container.append("</table>");

The above code generates the following HTML (tested in Chrome and Safari):

enter image description here

As you can see: The table is closed before the tr are injected.

The expected result is of course a table with three rows.

Question: Why is the code not generating the expected table, what am I missing here?

Community
  • 1
  • 1
Vingtoft
  • 13,368
  • 23
  • 86
  • 135

0 Answers0