【发布时间】:2026-01-30 11:10:02
【问题描述】:
使用 jQuery,如何匹配 DOM 树中当前元素之前的元素? 使用 prevAll() 只匹配之前的兄弟元素。
例如:
<table>
<tr>
<td class="findme">find this one</td>
</tr>
<tr>
<td><a href="#" class="myLinks">find the previous .findme</a></td>
</tr>
<tr>
<td class="findme">don't find this one</td>
</tr>
</table>
在我的具体情况下,我将在点击链接之前搜索 first .findme 元素。
【问题讨论】:
标签: javascript jquery