$.each(val, function(ind, va) {
console.log(ind)
console.log(va)
if (value.deductiontype == "1") {
var row = $('<div class="row" style="margin-top:6px;"><div class="col-md-12"><div class="col-md-2"><label class=" col-form-label">' + ind + '</label></div><div class="col-md-10"><input class="form-control payments" type="text" id="" placeholder="' + ind + '" value="' + va + '"/><div></div></div>');
$("#deduction_end_date").closest(".row").after(row);
} else if (value.deductiontype == "2") {
var row = $('<div class="row" style="margin-top:6px;"><div class="col-md-12"><div class="form-group"><div class="col-md-2"><label class=" col-form-label">' + ind + '</label></div><div class="col-md-10"><input class="form-control payments" type="text" id="" placeholder="' + ind + '" value="' + va + '"/></div></div></div></div>');
$("#deduction_end_date").closest(".row").after(row);
} else {
}
});
I have above code. what it does is it appends data on a table by iterating over the passed data. It is working ok except that the data in the table are from last to first.
I want to append the data from first to last
How can I use .after()
in a way that it will append from first to last