I tihnk the problem is that your are missing a tbody element.
You can use one stament in jQuery using find
, clone
, wrapAll
and closest
.
Code:
$(document).ready(function () {
var InputsWrapper = $("#input-table"); //Input boxes wrapper ID
var AddButton = $("#add-new"); //Add button ID
var inputId = 0; //to keep track of text box added
$(AddButton).click(function (e) //on add input button click
{
$(InputsWrapper).find('tbody:last').append($("#listItem" + inputId).clone(true, true).attr("id", "listItem" + (inputId + 1)).wrapAll("<tr><td>").closest("tr"));
inputId++; //Give the clone a unique id
return false;
});
});
Demo: http://jsfiddle.net/IrvinDominin/h7567/