why does appending values of select values in foo function
dos not trigger when I click add row button?
$(document).on("click", '.tdAdd', function () {
//alert($(this).closest('tr').index());
var newRow = $("<tr>");
var cols = "";
cols += '<td><input type="button" value="Add Row" class="tdAdd"/></td>';
cols += '<td><input type="button" value="Delete" class="tdAdd"/></td>';
cols += '<td><input type="text" /></td>';
cols += '<td><select class = "t">' + foo($(this).closest('tr').index() + 1) + '</select></td>';
newRow.append(cols);
newRow.insertAfter($(this).closest("tr"));
});
see this FIDDLE for demo.
function foo() {
var select = $('.t')
.append($("<option></option>")
.attr("value", 'one')
.text('One'));
select = $('.t')
.append($("<option></option>")
.attr("value", 'two')
.text('Two'));
}