选择器 - 在jQuery中选择页面上的所有表 [英] Selector - Selecting all tables on a page in jQuery

查看:55
本文介绍了选择器 - 在jQuery中选择页面上的所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在嵌入式div中的各个级别的页面上有多个表(没有ID或名称)。我的选择器是什么(如果可能的话)选择所有表而不管它在页面上的位置,并根据第一行中第一个单元格的内容迭代或过滤表格?

Say I have multiple tables (no IDs or names) on a page at various levels within embedded divs. What would my selector be (if it is possible) to select all tables regardless of where it resides on a page and iterate or filter the tables based on the content of the first cell in the first row?

推荐答案

您只需使用 $('table')作为选择器。

You can simply use $('table') as your selector.

然后你可以使用现有的过滤器,例如:contains :has .filter()函数,如果您需要更精细的控制来过滤结果。例如,

Then you can use the existing filters such as ":contains" or ":has", or the .filter() function if you need more finegrained control over in filtering your results. For example,

$('table:has(td > span)')

$('table').filter(function(index){
  return $(this).html() == "<tr><td>something</td></tr>";
});

这篇关于选择器 - 在jQuery中选择页面上的所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆