0

我需要在最顶层的 div“srch-sb-results”的上下文中选择具有“srch-maintop”类的深埋 div。如何使用 jquery 选择 srch-maintop div?

我离这里很近吗?

$('.srch-sb-results').next('table').find('td#MainLeftCell div.srch-maintop').delete();  

那也没碰过。。

<div class="srch-sb-results"> stuff here </div>
    <table>
       <tr>
          <td colspan='3'>
             <div style="border:1px solid silver"></div>
           </td>
         </tr>
         <tr>
             <td class="srch-leftcell">stuff</td>

            <td class="srch-mainleftcell">
               <div>stuff</div>
               <div class="srch-maintop"></div>
               <div class="srch-maintop2"></div>
            </td>

            <td class="srch-rightcell">stuff</td>
         </tr>

    <table>
4

4 回答 4

0

是的,你很接近;)

$('.srch-sb-results').next('table').find('td.srch-mainleftcell div.srch-maintop').delete();

于 2013-01-24T17:05:48.773 回答
0

我认为问题在于您写#MainLeftCellID,但您必须将其写为class .MainLeftCell。是的......你可以.remove()改用.delete()

于 2013-01-24T17:04:44.017 回答
0

如果给定类没有其他元素,您可以单独使用它:

$('.srch-maintop').remove();

或者在具有类 'srch-sb-results' 的 div 旁边的表中找到更具体的:

$('.srch-sb-results').next('table').find('.srch-maintop').remove();
于 2013-01-24T17:11:36.093 回答
0

使用remove()代替:

$('.srch-sb-results').next('table').find('td#MainLeftCell div.srch-maintop').remove(); 

并且没有classid命名MainLeftCell

于 2013-01-24T17:02:49.147 回答