类似于最接近的 jQuery 函数,它将返回父链之外的元素 [英] jQuery function similar to closest that will return elements outside of the parent chain
问题描述
是否有任何 jQuery 函数类似于最接近()会返回父链之外的元素,横向遍历?例如,我想在 div 源上调用一个函数 foo() 来返回 div 目标.我知道我可以使用 parent() 和兄弟姐妹 () 进行导航,但我需要一些通用的东西,可以根据需要向上、横向和向下移动多个级别?
var allsources = $('.source');allsources.click(function()){$(this).closest('.target').hide();});<div class="row"><div><div class="target" ></div>
<div><div><div class="source"></div>