[英]select div inside of table cell jquery
I need to select the deeply buried div with class "srch-maintop" with the context of the topmost div "srch-sb-results". 我需要选择最深层的div和“ srch-sb-results”作为最上层的div,该类具有“ srch-maintop”类。 How do I select the srch-maintop div using jquery? 如何使用jquery选择srch-maintop div?
Am I even close here? 我什至在这附近吗?
$('.srch-sb-results').next('table').find('td#MainLeftCell div.srch-maintop').delete();
That didn't even touch it.. 甚至都没有碰到它。
<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>
I think the problem is that you write #MainLeftCell
as ID , but you have to write it as class .MainLeftCell
. 我认为问题是您将#MainLeftCell
作为ID编写,但是必须将其编写为.MainLeftCell
类 。 And yes ... you can use .remove()
instead .delete()
是的...您可以使用.remove()
代替.delete()
是的,你很近;)
$('.srch-sb-results').next('table').find('td.srch-mainleftcell div.srch-maintop').delete();
If there is no other element with the given class you can just use it by itself: 如果给定类没有其他元素,则可以单独使用它:
$('.srch-maintop').remove();
Or to find a more specific one in the table next to the div with class 'srch-sb-results': 或者在div旁边的表中找到更具体的类“ srch-sb-results”:
$('.srch-sb-results').next('table').find('.srch-maintop').remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.