Reputation: 15200
I add content of table in Javascript like this
function (data) {
$("#forum-content").html(data);
}
data is a string with table content("<tr>...</tr><tr>...</tr>..."
) and I want to add that content to my table.
<table id="forum-content"></table>
In majority browsers it's look fine, but in IE 7 after adding content I don't see table anyway... I check that problem is that IE 7 is calculating size of my table 0(width=0,height=0) after adding content.
How can I solve this issue?
Upvotes: 0
Views: 170
Reputation: 38431
You should avoid writing a table body like that. In IE tables have been traditionally very fragile when using innerHTML
(which jQuery's html()
method basically is).
Try building the whole table instead:
function (data) {
$("#forum-content").html("<table>" + data + "</table>");
}
with
<div id="forum-content"></div>
Upvotes: 2
Reputation: 276
In my test, I saw nothing wrong. Do you check whether the content was added to the table? Is there any error thrown.
<table id="forum-content">
</table>
<script>
$(function() {
function addContent(data) {
$("#forum-content").html(data);
}
addContent('<tr><th>Title</th><td>Content</td></tr>');
});
</script>
</body>
Upvotes: 0