Highdel Highdel - 8 days ago 9
jQuery Question

Easy jQuery issue

If I have a table where a td has a class called "clicky" with the following jQuery code:

$(".clicky").click(function()
{
var td = $(this);
$.post("http://URL/file.php", {val:value})
.done(function(data)
{
$(td).empty().append("hello");
});
});


How can I replace the HTML in the td that was clicked with the HTML code returned in the data variable? I do not individually name my TDs, so I cannot reference it directly.

Simply using $(this).innerHTML() seems to be out of scope or dysfunctional...

Answer

Use html() to replace the existing innerHTML

td.html(data);