jQuery
New Wave Javascript


discuss » Selecting next sibling


Posted: Fri Mar 3 11:03:13 EST 2006
From: John Resig <jeresig at gmail.com >

Hi Klaus,

Yeah, the ancestor/sibling/preceding, etc. code isn't ready yet - but
it's a very high priority. I'll be sure to let you know when it's
done. Unfortunately, the code that you've shown will have to suffice
until I get this done:

$(this).next("p").toggle();

--John

On 3/3/06, Klaus Hartl <office at stilbuero.de> wrote:
> Hi there,
>
> is there an easy way in jQuery to simply select the next sibling? What I
> want to do is to toggle the succeeding <p> if I click on a <h3>:
>
> Thinking in jQuery, the following snippet is not the way to go I guess :-) :
>
> $("#register-faq h3").click(function() {
> var next = this.nextSibling;
> while(next.nodeName.toLowerCase() != "p") {
> next = next.nextSibling;
> }
> $(next).toggle();
> });
>
> I read about some more helper methods like .ancestor() and .siblings()
> in the blog, but didn't find any documentation about how to use them...
>
>
> Thank you for some help,
>
> Klaus
>
> _______________________________________________
> jQuery mailing list
> discuss at jquery.com
> http://jquery.com/discuss/
>


--
John Resig
http://ejohn.org/
jeresig at gmail.com