Javascript jQuery查找文本并从子元素中提取id

Javascript jQuery查找文本并从子元素中提取id,javascript,jquery,Javascript,Jquery,我试图在我所有的div中搜索某个文本“www.url.com” 如果找到www.url.com,我想从子表中提取表ID 我的html如下所示: <div class="box" id="results"> <div class="box-header"> <h1>www.url.com</h1> </div> <table cellpadding="0" cellspacing="0" border=

我试图在我所有的div中搜索某个文本“www.url.com”

如果找到www.url.com,我想从子表中提取表ID

我的html如下所示:

<div class="box" id="results">
   <div class="box-header">
      <h1>www.url.com</h1>
   </div>
   <table cellpadding="0" cellspacing="0" border="0" class="display" id="24">
      <thead>
         <tr>
            <th>col</th>
         </tr>
         <tr id="161">
            <td class="kw" style="border-left: 1px solid white;border-right: 1px solid #F4F4F4;padding: 12px 14px;position: relative;text-align: left;">111111</td>

         </tr>
      </thead>
      <tbody></tbody>
   </table>
不知道如何获取id:)

使用:

foundin.find('table').attr('id');
如果要收集所有实例,请使用以下方法:

foundin.each(function(){
    $(this).find('table').attr('id'); // Gets the ID
    // Store it into something like an array
});
使用:

如果要收集所有实例,请使用以下方法:

foundin.each(function(){
    $(this).find('table').attr('id'); // Gets the ID
    // Store it into something like an array
});

试试这个,如果所有的表看起来都一样,这应该可以

 $('*:contains("www.url.com")').find('table:first').attr('id');

试试这个,如果所有的表看起来都一样,这应该可以

 $('*:contains("www.url.com")').find('table:first').attr('id');

很好用!谢谢:)很好用!谢谢:)