我有这个 JavaScript block 代码:
var trows = table.getElementsByTagName('tbody')[0].rows;
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
trows[j].style.display = 'table-row';
}
在我实现这一行之前:
trows[j].style.display = 'table-row';
我需要检查具有特定索引的表行是否存在。
如果具有特定索引的表行存在,如何在 JavaScript 中检查?
最佳答案
因为 undefined
是假的,你可以这样做:
if (trows[j]) {
trows[j].style.display = 'table-row';
}
关于javascript - 如果存在具有特定索引的表行,如何检查 JavaScript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26868169/