shershams shershams - 2 years ago 92
HTML Question

jQuery appended table adds closing tag at the end of the text automatically. Why?


$.each(data, function(i, item){


Output gotten using


This code fires when ajax call is finished. Any ideas why is it doing so?

Assume that data variable is the valid json object.

Answer Source

Despite the abstraction that jQuery offers, you are operating on elements in the DOM, not tags in the HTML source.

jQuery('<table>') is shorthand for jQuery(document.createElement('table')).

You need to append your table rows to the table, not to the container (and likewise, the cells need to be added to the rows).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download