jquery - 确定 html 表中是否存在精确行

标签 jquery html-table

我想要与 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/

相关文章:

javascript - 使用 jQuery 删除某些字段

html - 带有 `position: absolute` 的内部按钮将放置在 table 外面

jquery - 如何在不使用循环的情况下突出显示 HTML 表格列?

jquery - 如何创建一个简单且独立于浏览器的工具提示?

javascript - 是 window.addEventListener ("load", init);比 $(function () { init(); }); 快?

javascript - 使用 JAVAScript 从 Phonegap 应用程序向 DJANGO 提交表单

jquery - 循环中生成的回流表无响应

php - 在 PHP MySQL 中每 30 分钟在表中插入空行以分隔时间

html - 如何覆盖嵌套表元素的 css 设置?

javascript - 重置按钮并启动倒数计时器