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
Not certain if this will be the fastest but...
$('#tableofdata tr td + td + td')
$("#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
how do we write it with $(this)
is $(this td:nth-child(3)) is valid or what will be the RIGHT way to do that
what about that solution :
$('#mytable tr').each(function() {
var customerId = $(this).find("td").eq(2).html();
}
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.
no the basic question is hot to get a selector with $(this)
here is the other question i ask... based on you code (tablerize)
http://stackoverflow.com/questions/656292/table-to-horizontal-bar-graph-in-jquery/656545#656545