【问题标题】:select all <table> tags that has <input> and <section> tags in them选择所有包含 <input> 和 <section> 标签的 <table> 标签
【发布时间】:2023-03-17 22:40:01
【问题描述】:

如何选择所有包含&lt;input&gt;&lt;section&gt; 标签的&lt;table&gt; 标签 - 通过 jQuery?

类似:

var tables_with_input = $( "table" that_contain input,section)  ///pseudo code

【问题讨论】:

  • 你想做什么?找到包含这些标签的&lt;table&gt; 会有多大用处?
  • 我做了 chrome 扩展,我尝试在页面中找到包含这些东西的所有表格,以便在之后对其进行操作

标签: javascript jquery html jquery-selectors


【解决方案1】:

您可以使用:has,它会检查匹配的元素是否包含某些元素等。

$('table:has(input, section)')

FIDDLE

【讨论】:

    【解决方案2】:
    var tables_with_input = $(context).find('table').has('input');
    

    【讨论】:

    • 感谢您的有趣回答!但是@adeneo 先给它:)
    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    相关资源
    最近更新 更多