I have a table with 14 table row and 3 column of data
i like to select the table, each row only the value of the #3 column
how do i count, i know the fisrt selector, the child... but how to not net
$('#tableofdata tr td).getmethethird
I have a table with 14 table row and 3 column of data
i like to select the table, each row only the value of the #3 column
how do i count, i know the fisrt selector, the child... but how to not net
$('#tableofdata tr td).getmethethird
$("#tableofdata tr td:nth-child(3)") or simply:
$("#tableofdata tr td:last-child") To grab the 3rd child from this, there are a number of ways:
$(this).find(":nth-child(3)"); or:
$(":nth-child(3)", this); or simply:
$(this)[2]; // arrays are 0 indexed Not certain if this will be the fastest but...
$('#tableofdata tr td + td + td') The problem with this solution:
$('#mytable tr').each(function() { var customerId = $(this).find("td").eq(2).html(); }); Is that if your table looks like this:
<table id='mytable'> <tr> <td>col1</td> <td>col2</td> <td>15</td> </tr> <tr> <td>col1</td> <td>col2</td> <td>16</td> </tr> </table> It would only get the ID of the first row because of the way it is constructed. So if you wanted to get all the IDs, you would do this:
var customers = new Array(); $('#mytable tr td:nth-child(2)').each(function() { customers.push($(this).html()); }); If you wanted the specific customer id of the Nth row, you would do this:
var customerId = $('#mytable tr').eq(N).find('td').eq(2).html(); Where N would be the 0-based index of the row you want.