GuyFromOverThere
GuyFromOverThere

Reputation: 471

Jquery fails to dynamically create a row cross browser

I have this function for my comment system but it doesn't dynamically add the row... This is what it looks like:

var myTable = $("#adddatacom"+id);
var magicNewRow = document.createElement('tr');
magicNewRow.htmlContent = '<td class="comments"><table><tr><td width="600px"><table><tr><td><?php echo $userimg2; ?></td><td><b><a href="profile.php">You</a>,</b><b style="color:green"> just now</b><br>'+ comMessage.val() +'</td></tr></table></td>';
magicNewRow.innerHTML = '<td class="comments" id="newcomm"><table><tr><td width="600px"><table><tr><td><?php echo $userimg2; ?></td><td><b><a href="profile.php">You</a>,</b><b style="color:green"> just now</b><br>'+ comMessage.val() +'</td></tr></table></td>';
myTable.append(magicNewRow);

Upvotes: 0

Views: 129

Answers (2)

Gaurav Shah
Gaurav Shah

Reputation: 5279

your syntax seems in correct

var myTable = $("#adddatacom"+id);
var magicNewRow = document.createElement('tr');
myTable.html('<td class="comments"><table><tr><td width="600px"><table><tr><td><?php echo $userimg2; ?></td><td><b><a href="profile.php">You</a>,</b><b style="color:green"> just now</b><br>'+ comMessage.val() +'</td></tr></table></td>');
magicNewRowhtml('<td class="comments" id="newcomm"><table><tr><td width="600px"><table><tr><td><?php echo $userimg2; ?></td><td><b><a href="profile.php">You</a>,</b><b style="color:green"> just now</b><br>'+ comMessage.val() +'</td></tr></table></td>');
myTable.append(magicNewRow);
$('#someelement').append(mytable);

Upvotes: 0

Rafay
Rafay

Reputation: 31033

you have to append myTable too to the document for example

document.append(myTable );

Upvotes: 2

Related Questions