我想要与 this question 的解决方案相同的解决方案而是确定表中是否实际存在行。 IE。我不想知道表中是否存在某个值,但我想知道确切的行 ( <tr ....></tr>
) 是否已经存在。
有什么想法吗:)?
最佳答案
如果您只需要检查表是否包含特定行,您可以这样做:
if($("#rowID").length){
//Horray you have the row you specified.
}
else{
//what you should do when the row doesn't exist
}
请注意,if($("#rowID").length)
意味着元素的长度不等于0,这意味着它存在,您还可以更改选择的方式元素与你可以做类似的事情 $("#tableID tr").length
.
希望对你有帮助
关于jquery - 确定 html 表中是否存在精确行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9279841/