Based on my code I want to push each row\'s inputs to each array. If it is row1, it should push all the input values of row 1 to array a1
. The second row\'s inputs
I'd use $.map
to create a nested array. It seems as if you want to have a lot of rows. So, I would recommend a 2d array instead of individual variables to avoid repetitive code. With a 2d array you can loop through each row; with individual variables you'd have to manually rewrite the same code for each row.
$('#check').click(function(event){
event.preventdefault;
var serialize = [];
$("#myTable tr").each(function () {
serialize.push($.map($(this).find("input"), function (ele) {
return ele.value;
}));
});
console.log(serialize);
});
1
1