Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
jQuery Closest Selector是否有替代选择器。我注意到它在 1.7 中已弃用并在 1.8 中删除。我目前在我的 JavaScript 中使用了很多它,我很想知道是否有类似的东西可以有效地使用。
它没有被弃用。只是返回数组的内部方法。来自 jQuery 文档:
此签名(仅!)在 jQuery 1.7 中已弃用,并在 jQuery 1.8 中删除。它主要是供内部使用或由插件作者使用。
closest顺便说一句,这应该与(在一个元素上)表现相同:
closest
$el.parents( selector ).eq(0)
仅.closest( selectors [, context ] )删除了方法签名。其他一切都很好!
.closest( selectors [, context ] )