Reputation: 15630
I have a html table and I need to get the first row's (which is not the thead part.It will be in tbody part) last columns value or text. I need the value on clicking the button btnAdd
<table>
<thead>
<tr>
<td>Name</td>
<td>ID</td>
</tr>
</thead>
<tbody>
<tr>
<td>Edwin</td>
<td><span style='display:none'>1</span></td>
</tr>
</tbody>
</table>
<input type='btnAdd' runat='server' >
Upvotes: 2
Views: 6229
Reputation: 8117
$("button").click(function(){
var columnText = $("TABLE TBODY TR:first TD:last").html();
}
Upvotes: 0
Reputation: 253308
This should work, I think:
$('btnAdd').click(
function(){
var text = $('tbody > tr:first > td:last').text();
});
Upvotes: 1