I have four HTML tables and have to compare data from one table with one that is selected by the user. I am passing the user-selected table ID into this function, but I don’t know how to loop through the rows of this table:
function callme(code) {
var tableName = 'table'+code;
//alert(tableName);
//How to do loop for this table?? HELP!!
$('#tableName tr').each(function() { //how to do
if (!this.rowIndex) return; // skip first row
var customerId = $(this).find("td").eq(0).html();
alert(customerId);
// call compare function here.
});
}
It should be something very simple for a experienced jQuery programmer. Here is my jsfiddle: http://jsfiddle.net/w7akB/66/
You are using bad selector, this:
means get all
trfrom table with idtableName. This is what you want to do:so you will select table with id stored inside
tableNamevariable.