each loop on table in jquery code example
Example 1: jquery for each tr in td
$(tr).find('td').each (function (index, td) {
console.log(td)
});
$('#tableContent tr').each(function(index, tr) {
$(tr).find('td').each (function (index, td) {
console.log(td)
});
});
Example 2: iterate table in jquery
$(".button").on('click', function () {
$("#myTable tr").each(function () {
var self = $(this);
var col_1_value = self.find("td:eq(0)").text().trim();
var col_2_value = self.find("td:eq(1)").text().trim();
var col_3_value = self.find("td:eq(2)").text().trim();
var col_4_value = self.find("td:eq(3)").text().trim();
var result = col_1_value + " - " + col_2_value + " - " + col_3_value + " - " + col_4_value;
console.log(result);
});
});