Look at the following:
<table border="0" id="npoGridView">
<thead>
<tr>
<th>Quantity Order</th>
<th>Cost P.U</th>
<th>Total</th>
</tr>
</thead>
<tbody>
//TD .......
</tbody>
<tfoot>
<tr>
<th>Quantity Order</th>
<th>Cost P.U</th>
<th id="15">Total</th>
</tr>
</tfoot>
</table>
I have given id to th in tfoot (i.e. id="15"), Now I want to get th value using jquery.
How to get the specific th value form footer using jquery?
$('#npoGridView tfoot').each(function() {
console.log($('th', this).text());
});
To get the value of any specific th like <th id="15">Total</th>;
$('tfoot th#15').text();
you can get the value of th like following:
$('tfoot th:eq(0)').text(); // output: Quantity Order
$('tfoot th:eq(1)').text(); // output: Cost P.U
$('tfoot th:eq(2)').text(); // output: Total
You could use .text() or .html() as you need.
To update value of th then use:
$('tfoot th#15').html($grandTotal);
or
$('tfoot th#15').text($grandTotal);
NOTE Don't use only numeric value as id .
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