admin管理员组文章数量:1023213
I have this JavaScript block code:
var trows = table.getElementsByTagName('tbody')[0].rows;
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
trows[j].style.display = 'table-row';
}
Before I implement this row:
trows[j].style.display = 'table-row';
I need to check if table row with scpecific index exists.
How to check in JavaScript if table row with specific index exist?
I have this JavaScript block code:
var trows = table.getElementsByTagName('tbody')[0].rows;
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
trows[j].style.display = 'table-row';
}
Before I implement this row:
trows[j].style.display = 'table-row';
I need to check if table row with scpecific index exists.
How to check in JavaScript if table row with specific index exist?
Share Improve this question edited Nov 11, 2014 at 15:37 Kashif Umair Liaqat 1,0741 gold badge19 silver badges27 bronze badges asked Nov 11, 2014 at 15:18 MichaelMichael 13.6k59 gold badges170 silver badges315 bronze badges 3- Is jQuery an option? – puelo Commented Nov 11, 2014 at 15:20
- 2 trows[j].value != undefined – Mahmoud.Eskandari Commented Nov 11, 2014 at 15:22
- No I don't use jQuery – Michael Commented Nov 11, 2014 at 15:27
2 Answers
Reset to default 5Since undefined
is falsey, you can just do this:
if (trows[j]) {
trows[j].style.display = 'table-row';
}
if(typeof trows[j] !== 'undefined') {
trows[j].style.display = 'table-row';
}
You can check if the type is undefined.
I have this JavaScript block code:
var trows = table.getElementsByTagName('tbody')[0].rows;
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
trows[j].style.display = 'table-row';
}
Before I implement this row:
trows[j].style.display = 'table-row';
I need to check if table row with scpecific index exists.
How to check in JavaScript if table row with specific index exist?
I have this JavaScript block code:
var trows = table.getElementsByTagName('tbody')[0].rows;
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
trows[j].style.display = 'table-row';
}
Before I implement this row:
trows[j].style.display = 'table-row';
I need to check if table row with scpecific index exists.
How to check in JavaScript if table row with specific index exist?
Share Improve this question edited Nov 11, 2014 at 15:37 Kashif Umair Liaqat 1,0741 gold badge19 silver badges27 bronze badges asked Nov 11, 2014 at 15:18 MichaelMichael 13.6k59 gold badges170 silver badges315 bronze badges 3- Is jQuery an option? – puelo Commented Nov 11, 2014 at 15:20
- 2 trows[j].value != undefined – Mahmoud.Eskandari Commented Nov 11, 2014 at 15:22
- No I don't use jQuery – Michael Commented Nov 11, 2014 at 15:27
2 Answers
Reset to default 5Since undefined
is falsey, you can just do this:
if (trows[j]) {
trows[j].style.display = 'table-row';
}
if(typeof trows[j] !== 'undefined') {
trows[j].style.display = 'table-row';
}
You can check if the type is undefined.
本文标签: How to check in JavaScript if table row with specific index existStack Overflow
版权声明:本文标题:How to check in JavaScript if table row with specific index exist? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745596886a2158223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论