我想 Select img
个标签,它们不在table
下包装.下面的代码应该只返回1个长度,因为这个HTML只有1img
个标记,不在table
下.
Note :不可能更改标记/样式.
console.log(document.querySelectorAll('img').length)
<table align="center">
<tbody>
<tr>
<td style="text-align: center;">
<a href="https://xxx" imageanchor="1" style="margin-left: auto; margin-right: auto;">
<img border="0" src="https://xxx" original="https://xxx" style="">
</a>
</td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">Double Trailing</td>
</tr>
</tbody>
</table>
<a href="https://xxx" imageanchor="1" style="margin-left: auto; margin-right: auto;">
<img border="0" src="https://xxx" original="https://yyy" style="">
</a>