请建议我 我的代码:
$('.Create-New-Order').click(function () {
var totalRowCount = $("#table_New_Order tbody tr").length;
alert(totalRowCount);
});
答案 0 :(得分:1)
$(function() {
$('.Create-New-Order').click(function() {
var total = $('#mytbl tr').length ;
alert('tr count = '+ total);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<table border="1px solid red">
<tr>
<th>Name</th><th>Email</th>
</tr>
<tbody id="mytbl">
<tr>
<td>sfdsd</td><td>tsdaf@ymail.com</td>
</tr>
<tr>
<td>sfdsd</td><td>tsdaf@ymail.com</td>
</tr>
<tr>
<td>sfdsd</td><td>tsdaf@ymail.com</td>
</tr>
</tbody>
</table>
<br>
<br>
<a href="#" class="Create-New-Order">Create-New-Order</a>