开发者

Jquery fails to dynamically create a row cross browser

开发者 https://www.devze.com 2023-04-01 18:36 出处:网络
I have this function for my comment system but it doesn\'t dynamically add the row... This is what it looks like:

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&开发者_如何学Clt;/a>,</b><b style="color:green"> just now</b><br>'+ comMessage.val() +'</td></tr></table></td>';
myTable.append(magicNewRow);


you have to append myTable too to the document for example

document.append(myTable );


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号