-1

Why this code:

row.append($("<td></td>").text("someText"));

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

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user169242
  • 67
  • 1
  • 2
  • 4

1 Answers1

10

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>")
Russ Cam
  • 124,184
  • 33
  • 204
  • 266