不确定为什么这不起作用,但我有:
https://jsfiddle.net/m9uqdx5y/
<div class="sectionContent">
<span class="open"><a>top</a></span>
<span class="closeEditorLink"><a>bottom</a></span>
</div>
var $preDiv = $('.closeEditorLink');
$($preDiv).click(function () {
$($preDiv).closest('.sectionContent a').focus();
});
我只需要关注上面的 A 标签。
最佳答案
.closeEditorLink
不是 .sectionContent a
的子项,因此 .closest(".sectionContent a")
什么也没有。
试试 .closest('.sectionContent').find('.open a').focus();
代替。
关于jquery - .closest .prev jquery 无法专注于上面的 A 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39858258/