removing and appending rows to tables

removing and appending rows to tables

I have 4 tables on a page with similar structure.  Differences are the table id's and the number of tds per row, two tables have 2 per row, the other two have 4.  Basic structure is:

  1. <table id="mytable"> <tbody> <tr id="tempRowID"> <td class="delete"> <img src="myImage.png" /> </td> </tr> </tbody> </table>​​​​​​​​​​​​​​​​​​​
And the query is:

  1.     $(document).on('click', 'table td', function () {

  2.         var blankRowShort = "<tr id='tempRowID'><td colspan = 2>No Information entered.</td></tr>";
  3.         var blankRowLong = "<tr id='tempRowID'><td colspan = 4>No Information entered.</td></tr>";
  4.         var currentTable = $(this).closest('table').attr("id");

  5.         $(this).parent().remove();

  6.         if ((currentTable == "IDTable") || (currentTable == "aliasTable")) {

  7.             $(this).parent().append(blankRowLong);
  8.         }
  9.         else {
  10.             $(this).parent().append(blankRowShort);
  11.         }

  12.     });

So the function works great, until the if statement.  Line 8 removes the row but then I need to add one of the generic 'no info' rows depending on which table and nothing I try seems to work.  Some other things I've tried are:

  1. $(this).closest('table').append(blankRowShort);

  1.             $('"#' + currentTable + '"').parent().append(blankRowLong);

Some ideas would be great, thank you.