【发布时间】:2011-05-22 05:25:23
【问题描述】:
什么是 Zepto.js 替代 jQuery 的$(this).parent().parent().find('.active')?
【问题讨论】:
标签: javascript zepto
什么是 Zepto.js 替代 jQuery 的$(this).parent().parent().find('.active')?
【问题讨论】:
标签: javascript zepto
这个问题大约有 4 个月的历史,Zepto 框架会定期更新。
$(this).parent().parent().find('.active') 现在可以使用了。
根据 git repo 源代码树,此支持由 Mislav Marohnić 于 2010 年 12 月 20 日添加(提交哈希 784de340)。
【讨论】:
我在API 中没有看到.parent() 方法,因此您可能只需要这样做(未经测试!):
$($(this).get(0).parentNode.parentNode).find('.active').hide();
【讨论】:
zepto 有类似 Element#upfrom 原型的东西来搜索祖先。它被称为closest。您需要有一个班级或知道谁是家长。
$(this).closest("div.parentclass").find('.active')
【讨论】:
Zepto 已经实现了 .parent() 方法。见http://zeptojs.com/#parent
【讨论】: