Javascript 如果链接没有href,是否隐藏父TR?
我现在有:Javascript 如果链接没有href,是否隐藏父TR?,javascript,jquery,Javascript,Jquery,我现在有: <table> <tbody> <tr> <td> <a href="http://www.google.com">Visit Website</a> </td> </tr> <tr> <td>
<table>
<tbody>
<tr>
<td>
<a href="http://www.google.com">Visit Website</a>
</td>
</tr>
<tr>
<td>
<a href="">Visit Website</a>
</td>
</tr>
<tr>
<td>
<a href="http://www.google.com">Visit Website</a>
</td>
</tr>
<tr>
<td>
<a href="">Visit Website</a>
</td>
</tr>
</tbody>
</table>
我需要一些javascript来:
如果没有href href=则隐藏包装它的TR
如何使用javascript实现这一点?如果您只想检查href=
试一试
$('a[href=""]').parent().parent().hide();
$('a[href=""],a:not([href])').parent().parent().hide();
或
如果您还想只检查href=或不检查给定的href属性
试一试
$('a[href=""]').parent().parent().hide();
$('a[href=""],a:not([href])').parent().parent().hide();
或
您可以使用href=获取标记,然后使用
$'a[href=]'。最近的'tr'。隐藏;
现在就看一看它的工作原理,请检查一下只是为了学究,从技术上讲,你不能说它没有href。