我有以下psudeo html。我需要编写一些jquery,它隐藏任何不包含具有某个类'FacetItemsActive'的锚标记的表的行。
<table >
<tr>
<td>
<table>
<tr>
<td><a class='FacetItemsActive'/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
normal content
</td>
</tr>
<tr>
<td>
normal content
</td>
</tr>
</table>
我有这个功能很接近但不完全存在。你们这些jquery大师能帮助我吗?
function eiaHideNonSelectedFacets(){
// find the parent facet table
// find children tr of that table, and hide any rows that do not contain the class 'FacetItemsActive'
$('.FacetItemsActive').closest('table[facet]').find('tr').each(function(){
if (! $(this).is('.FacetItemsActive')){
$(this).hide();
}
});
}
答案 0 :(得分:5)
$("tr:not(:has('.FacetItemsActive'))").hide();
答案 1 :(得分:0)
这不是你关闭“a”标签的方式。 应该使用。