I have the following div:
<div data-object-id="dsOrders" class = "OrderList" >
<div class="table-responsive m-y-1">
<table class="table">
<thead>
<tr>
<th style="width:110px;">ID</th>
<th style="width:110px;"> Order Date</th>
</tr>
<!-- FILTER ROW -->
<tr>
<td>
<input data-search="OrderID" class="form-control form-control-sm">
</td>
<td>
<input data-search="OrderDate" class="form-control form-control-sm">
</td>
</tr>
</thead>
<tbody>
<tr data-repeat data-active>
<td data-field="OrderID" class = "OrderID"></td>
<td data-field="OrderDate"></td>
</tr>
</tbody>
</table>
</div>
</div>
How do I make it select the last row of it with javascript or jquery? I've tried doing it like this
$("[.OrderList][tr:last]").focus();
But with no success
使用此代码:
.OrderList >.table > tbody > tr:last-child { background:#ff0000; }
Try this :
$('#yourtableid tr:last').attr('id');
or this:
$("#TableId").find("tr").last();
Hope this if helpful :)
$('#yourtableid tr:last').attr('id').focus();
or
$('#yourtableid tr:last')[0].focus();
should work.
console.log($(".OrderList table tr:last").html())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div data-object-id="dsOrders" class = "OrderList" > <div class="table-responsive my-1"> <table class="table"> <thead> <tr> <th style="width:110px;">ID</th> <th style="width:110px;"> Order Date</th> </tr> <!-- FILTER ROW --> <tr> <td> <input data-search="OrderID" class="form-control form-control-sm"> </td> <td> <input data-search="OrderDate" class="form-control form-control-sm"> </td> </tr> </thead> <tbody> <tr data-repeat data-active> <td data-field="OrderID" class = "OrderID"></td> <td data-field="OrderDate"></td> </tr> </tbody> </table> </div> </div>
console.log($(".OrderList tr").last().html())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div data-object-id="dsOrders" class = "OrderList" > <div class="table-responsive my-1"> <table class="table"> <thead> <tr> <th style="width:110px;">ID</th> <th style="width:110px;"> Order Date</th> </tr> <!-- FILTER ROW --> <tr> <td> <input data-search="OrderID" class="form-control form-control-sm"> </td> <td> <input data-search="OrderDate" class="form-control form-control-sm"> </td> </tr> </thead> <tbody> <tr data-repeat data-active> <td data-field="OrderID" class = "OrderID"></td> <td data-field="OrderDate"></td> </tr> </tbody> </table> </div> </div>
尝试此代码,您可以通过以下方法实现它:
$('#first table:last tr:last')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.