非常快速的点。我在这里看到了非常类似的问题,但他们通常使用表ID或假定只有一个表。我有一个使用相同模板(没有唯一ID)的许多表的页面,并想知道是否加载特定数据时,如果行是空的。我曾尝试:JQuery获得行数
jQuery: count number of rows in a table
Jquery- Get the value of first td in table和许多其他
//var row = $(this).closest('table tbody:tr:first');
// var row = $(this).closest('tr').children('td:first').text();
// var row = $(this).closest('tr').length;
// var row = $(this).closest('tr').children('td:first').length;
// var row = $(this).closest('table').find("tbody").children().length;
// var row = $(this).closest('table').children('tr:last').index() + 1;
// var row = $(this).closest('table').rowIndex;
// var row = $("tbody").has("tr");
// var row = $(this).closest('tbody').has("tr");
var row = $('#tbody').children('tr:first').length;
,但不能得到正确的答案。
下面是表的结构:
这是指什么元素? –
要计算你可以使用$()的元素长度 –
看起来你应该看看[jQuery学习中心](https://learn.jquery.com/) – Andreas