What's Zepto.js alternative to jQuery's $(this).parent().parent().find('.active')?
Asked Answered
L

4

5

What's Zepto.js alternative to jQuery's $(this).parent().parent().find('.active')?

Lignify answered 8/12, 2010 at 13:4 Comment(0)
M
4

I don't see a .parent() method in the API, so you might just have to do this (untested!):

$($(this).get(0).parentNode.parentNode).find('.active').hide();
Mickens answered 8/12, 2010 at 13:22 Comment(0)
M
9

This question is about 4 months old and the Zepto framework gets updated pretty regularly.

$(this).parent().parent().find('.active') now works.

According to the git repo source tree, this support was added in Dec 20, 2010 by Mislav Marohnić (commit hash 784de340).

Monomial answered 19/4, 2011 at 22:8 Comment(0)
M
4

I don't see a .parent() method in the API, so you might just have to do this (untested!):

$($(this).get(0).parentNode.parentNode).find('.active').hide();
Mickens answered 8/12, 2010 at 13:22 Comment(0)
L
3

zepto has something like Element#upfrom prototype to search up the ancestry. It's called closest. You'll need to have a class or know who is the parent.

$(this).closest("div.parentclass").find('.active')
Legalize answered 9/12, 2010 at 21:18 Comment(1)
Thank you. I doubt if it's faster than karim79's solution, tho.Lignify
C
1

Zepto has since implemented the .parent() method. See http://zeptojs.com/#parent

Campanulaceous answered 3/3, 2013 at 21:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.