I have a method that adds an image to a TD and attaches the click event to the image. I am dynamically building a row and wanted to attach the TD image column to my row.
$("<tr></tr>").append(addActionColumn($("<td></td>")));
And here is my addActionColumn method:
function addActionColumn(td) {
var actionImage = document.createElement("img");
$(actionImage).attr("src", "../Images/cross_red.JPG");
// delete the row
$(actionImage).click(function() {
$(td).parent().remove();
});
$(td).append(actionImage);
}
For some reason the TR never gets the image column attached to it.