$.append adding to last element in table row instead of creating new row

$.append adding to last element in table row instead of creating new row

Hello,

Im trying to insert a new row in a table. But instead its appending to the last element in the row. Ive done this a hundred times, and it's not working now 

I should have gone into underwater demolition like my mother wanted me to ... 

  1. // Add container                                                      
  2. $("#dtltbl").on("click", ".addCont", (function () {                   
  3.   var $classes = $(this).closest("tr").prop("class");             
  4.   var $class = "." + $.trim($classes.replace("itemno",""));           
  5.   var $dtl = $("#dtltmpl").html();  // variable that stores table row                                  
  6.   $($class).next('tr').append($($dtl));  //added to last element of current row                             
  7. }));