Thursday, 5 September 2013

returning 1st column from table over and over again

returning 1st column from table over and over again

I am trying to get the value of my td column with a specific class
(tablecellname):
$('#MainContent_myTable tr').each(function () {
console.log($('.tablecellname').html());
});
I think I get the correct amount of rows in the table but it only gives me
the 1st value (repeated).
<table id='MainContent_myTable'>
<tr>
<td class='tablecellname'>abc</td>
<td class='tablecellcode'>111</td>
</tr>
<tr>
<td class='tablecellname'>def</td>
<td class='tablecellcode'>222</td>
</tr>
<tr>
<td class='tablecellname'>ghi</td>
<td class='tablecellcode'>333</td>
</tr>
<tr>
<td class='tablecellname'>jkl</td>
<td class='tablecellcode'>444</td>
</tr>
<tr>
<td class='tablecellname'>mno</td>
<td class='tablecellcode'>555</td>
</tr>
<tr>
<td class='tablecellname'>pqr</td>
<td class='tablecellcode'>666</td>
</tr>
<tr>
<td class='tablecellname'>stu</td>
<td class='tablecellcode'>777</td>
</tr>
<tr>
<td class='tablecellname'>vwx</td>
<td class='tablecellcode'>888</td>
</tr>
<tr>
<td class='tablecellname'>yz</td>
<td class='tablecellcode'>999</td>
</tr>
</table>
It only prints abc over and over again.
What am I doing incorrectly?

No comments:

Post a Comment