我有一个2列“id”(唯一值)和“名称”的表。使用jQuery我想返回ID与ID数组(例如SR1,B1,B2)匹配的行数(.length),并且这些行的“name”字段中的值为空。jquery查找具有2列中特定值的表行数
到目前为止,我有:
var empty = $('[tabulator-field="name"]:empty').length;
var sr1 = $('.tabulator-row:nth-of-type(29) [tabulator-field="name"]:empty').length;
var sr2 = $('.tabulator-row:nth-of-type(30) [tabulator-field="name"]:empty').length;
var b1 = $('.tabulator-row:nth-of-type(7) [tabulator-field="name"]:empty').length;
var b2 = $('.tabulator-row:nth-of-type(8) [tabulator-field="name"]:empty').length;
var c10 = $('.tabulator-row:nth-of-type(27) [tabulator-field="name"]:empty').length;
var c11 = $('.tabulator-row:nth-of-type(28) [tabulator-field="name"]:empty').length;
var emptySR = sr1 + sr2 + b1 + b2 + c10 + c11;
var emptyBeds = empty - emptySR;
然而,这似乎是一种低效的方式来计算这一点,此外,选择通过自己的位置,我感兴趣的是表中的行(而不是他们的ID值)使用:nth-of-type会返回不正确的结果,如果该表按行的顺序将更改,则按不同的字段排序。
请任何人都可以提出一个强大的功能,实现我所需要的?
请点击'<>'并张贴[MCVE] – mplungjan
不知道为什么我要发布一个例子 - 这是关于选择和使用jQuery和上下文过滤元件中有很好的描述一个简单的问题,我首段。 –
@TomHeaps实际html的spinet会有帮助。 – nurdyguy