开发者

Adding text to a table data cell with jQuery

Why this code:

row.append($("<td></td&g开发者_高级运维t;").text("someText"));

...isn't working, and how can I fix it?


The code works fine, as demonstrated with this Working Demo. Add /edit to the URL to see the code. Tested in Firefox 3.5 and IE 6

$('button').one('click', function() {
  $('#myTable tr:last').append($("<td></td>").text("someText"));
});

Also, you might consider shortening the creation of the cell element to

$("<td>someText</td>")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜