javascript - $this - can't find the correct jQuery selector -
i'm having real trouble finding selectors use show divs on page html structure overly complicated (wordpress comments system).
instead of pasting here i've created simplified version of layout , created couple of fiddles.
- this full page div's displayed :
https://jsfiddle.net/e25zvfyg/
- this how want work. reply box , associated existing comments hidden until "reply" clicked , hidden divs slidedown. i've included "non-working" js in fiddle. can show me i'm going wrong?
https://jsfiddle.net/yf3oagx7/
(function ($) { $('.single-f3ed-reply').hide(); $('.f3ed-reply').hide(); $('a.this-reply').click(function () { $('.single-f3ed-reply').hide(); $(this).parents().next('.single-f3ed-reply').slidedown('fast'); $(this).parents().next('.f3ed-reply').slidedown('fast'); return false; }); })(jquery);
any appreciated.
.parents()
returns all elements above selected element. don't want this, want go far containing div/wrapper.
.next()
returns next item (filtered), makes no sense in context of parents()
go nearest wrapping div (closest
), down again (find
) item want:
$(this).closest(".stream-wrap").find('.single-f3ed-reply').slidedown('fast'); $(this).closest(".stream-wrap").find('.f3ed-reply').slidedown('fast');
Comments
Post a Comment