I know it's already been asked before, however I've tried previous solutions and they're not working for me.
I've got a HTML table as so which is being generated by AJAX:
<table cellspacing="1" cellpadding="7" summary="Procedure Tabulate: Table 1" frame="box" rules="groups" class="table table-bordered table-hover">
<thead>
<tr>
<th scope="col" class="c m Header"> </th>
<th scope="col" class="c Header">reel</th>
<th scope="col" class="c Header">budgete</th>
<th scope="col" class="c Header">ecart</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" class="l t RowHeader">Fours</th>
<td class="r b Data">15 341,10</td>
<td class="r b Data">15 540,90</td>
<td nowrap="" class="r b Data"> -1.29% </td>
</tr>
<tr>
<th scope="row" class="l t RowHeader">Hifi</th>
<td class="r b Data">10 578,60</td>
<td class="r b Data"> 9 962,50</td>
<td class="r b Data"> 6.18% </td>
</tr>
<tr>
<th scope="row" class="l t RowHeader">Magneto</th>
<td class="r b Data">10 090,10</td>
<td class="r b Data">10 495,60</td>
<td nowrap="" class="r b Data"> -3.86% </td>
</tr>
<tr>
<th scope="row" class="l t RowHeader">Total</th>
<td class="r b Data">36 009,80</td>
<td class="r b Data">35 999,00</td>
<td class="r b Data"> 1.04% </td>
</tr>
</tbody>
</table>
I don't have much control over the classes in the table as they are being created by another group of people using SAS (Statistical Analysis Software).
I would like to get the last td of each row in tbody.
For the moment I've got the following jQuery to do the job:
$( '#ajax-area table tbody tr td:last' ).addClass( 'result' );
This isn't adding the class to the td.
Does anyone have a solution?
Approach 2: Use $('table tr:last') jQuery Selector to find the last element of the table. The 'table' in query looks for the table element then 'tr' is looking for all the rows in the table element and ':last' is looking for the last table row of the table.
The TH and TD elements are used for table cells. TH is used for table header cells while TD is used for table data cells. This distinction gives user agents a means to render such cells distinctly, for instance by using a larger or heavier font for header cells. It is also needed when rendering to speech.
A TD Lines trendline is drawn through two TD Points. A supply trendline is drawn between a TD Point high (Point “B”) and the most recent prior TD Point low (point “A”) that is strictly greater than point B. The line is then extended to the right of point B according to the rules below.
Try
$( 'table tbody tr td:last-child').addClass( 'result' );
Demo: Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With