Reputation: 583
I have the following HTML:
<tr data-uid="2639f8d8-5459-42fb-b51c-b071db6c1541" role="row">
<td class="" role="gridcell">1</td>
<td class="" role="gridcell">06/12/2018</td>
<td class="" role="gridcell">Feeding</td>
<td class="" role="gridcell">some long text data</td>
<td class="k-command-cell" role="gridcell">
<a role="button" class="k-button k-button-icontext k-grid-ViewDetails"
href="#">View Details</a></td>
</tr>
There are many rows in the table like this one.... I need to get the ID value which in this case is '1'. I have tried to get the attribute role value but no luck.
Upvotes: 0
Views: 222
Reputation: 3917
I'm not sure what exactly your question is, but I'm posting an simple example of collecting all ids in the table.
$(function(){
var ids = $('tr').map(function(){
return $(this).children('td').first().text()
}).get();
console.log(ids);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<table>
<tr data-uid="2639f8d8-5459-42fb-b51c-b071db6c1541" role="row">
<td class="" role="gridcell">1</td>
<td class="" role="gridcell">06/12/2018</td>
<td class="" role="gridcell">Feeding</td>
<td class="" role="gridcell">some long text data</td>
<td class="k-command-cell" role="gridcell">
<a role="button" class="k-button k-button-icontext k-grid-ViewDetails"
href="#">View Details</a></td>
</tr>
<tr data-uid="2639f8d8-5459-42fb-b51c-b071db6c1541" role="row">
<td class="" role="gridcell">2</td>
<td class="" role="gridcell">07/12/2018</td>
<td class="" role="gridcell">Feeding 2</td>
<td class="" role="gridcell">some long text data ...</td>
<td class="k-command-cell" role="gridcell">
<a role="button" class="k-button k-button-icontext k-grid-ViewDetails"
href="#">View Details</a></td>
</tr>
</table>
Upvotes: 1