I have a table containing a variable number of columns. I wrote a function to iterate through each cell in each row to do the following:
When you select td
pass the context as tr(this
) so that it will look for td
only in the current tr
. Try this.
$("#MarketsTable tr").each(function () {
$('td', this).each(function () {
var value = $(this).find(":input").val();
var values = 100 - value + ', ' + value;
if (value > 0) {
$(this).append(htmlPre + values + htmlPost);
}
})
})