[jQuery] Possible next()/prev() bug?
Hi all, I've come across what is possibly a bug (or unexpected behaviour) when using next(). I have an example page setup here: http://fapdragon.com/test/test.html As far as I can see, the filter for next() is not being applied and it always returns the next DOM element. Can anyone comment on this or should I log a ticket for it? Thanks, Evan -- View this message in context: http://www.nabble.com/Possible-next%28%29-prev%28%29-bug--tf3422183.html#a9538163 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Possible next()/prev() bug?
.next() and .prev() only work with the next (or previous) /immediate/ element. In your example, the next element is actually a - which your filter doesn't match. Currently there isn't a way to do what you want (easily) in jQuery. I'd imagine it being something like .nextClosest("div.myDiv"). The next best thing that I can think of would be to do: $(this).next().next("div.myDiv") Hope that helps. --John On 3/18/07, EvanT <[EMAIL PROTECTED]> wrote: > > Hi all, > > I've come across what is possibly a bug (or unexpected behaviour) when using > next(). > > I have an example page setup here: http://fapdragon.com/test/test.html > > As far as I can see, the filter for next() is not being applied and it > always returns the next DOM element. > > Can anyone comment on this or should I log a ticket for it? > > Thanks, > Evan > -- > View this message in context: > http://www.nabble.com/Possible-next%28%29-prev%28%29-bug--tf3422183.html#a9538163 > Sent from the JQuery mailing list archive at Nabble.com. > > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Possible next()/prev() bug?
Thanks John, I thought it might have been the case, the documentation is a little ambiguous. It would be nice to see a function like $(selector).after(filter) that finds the next matching element (I know that after is already used for DOM manipulation) and a similar one for prev() Cheers, Evan John Resig wrote: > > .next() and .prev() only work with the next (or previous) /immediate/ > element. In your example, the next element is actually a - which > your filter doesn't match. > > Currently there isn't a way to do what you want (easily) in jQuery. > I'd imagine it being something like .nextClosest("div.myDiv"). The > next best thing that I can think of would be to do: > > $(this).next().next("div.myDiv") > > Hope that helps. > > --John > > On 3/18/07, EvanT <[EMAIL PROTECTED]> wrote: >> >> Hi all, >> >> I've come across what is possibly a bug (or unexpected behaviour) when >> using >> next(). >> >> I have an example page setup here: http://fapdragon.com/test/test.html >> >> As far as I can see, the filter for next() is not being applied and it >> always returns the next DOM element. >> >> Can anyone comment on this or should I log a ticket for it? >> >> Thanks, >> Evan >> -- >> View this message in context: >> http://www.nabble.com/Possible-next%28%29-prev%28%29-bug--tf3422183.html#a9538163 >> Sent from the JQuery mailing list archive at Nabble.com. >> >> >> ___ >> jQuery mailing list >> discuss@jquery.com >> http://jquery.com/discuss/ >> > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > > -- View this message in context: http://www.nabble.com/Possible-next%28%29-prev%28%29-bug--tf3422183.html#a9543998 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/