javascript - 如何从传递的表中获取行数?
问题描述
我有传递表格的功能:
function isEmpty(properTable){
}
var isEmpty1 = isEmpty($("#daysTable tbody"));
var isEmpty2 = isEmpty($("#daysTable2 tbody"));
而且我不知道如何确定表是否为空或该表有多少行。我需要这样的东西:
function isEmpty(properTable){
if((properTable tr).length > 0){
return false;
}
else{
return true;
}
}
当然它不起作用。
解决方案
.find()
与您的properTable
参数一起使用以计算表体中的行数:
改变
if((properTable tr).length > 0){
至
if(properTable).find('tr').length === 0){