开发者

Adding text to a table data cell with jQuery

开发者 https://www.devze.com 2022-12-13 04:25 出处:网络
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 /

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

精彩评论

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

关注公众号