#766 closed bug (fixed)
$(SELECTOR).next() and $(SELECTOR).prev() are not working
Reported by: | himynameiznate | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1a |
Component: | core | Version: | 1.1a |
Keywords: | siblings | Cc: | |
Blocked by: | Blocking: |
Description
When looking for siblings in 1.1a, the .next() and .prev() functions do not return anything, even when there are clearly siblings.
Example code:
<p id="first">First paragraph</p>[[BR]] <p id="second">Second paragraph</p>[[BR]] <p id="third">Third paragraph</p>[[BR]] <script> console.log($('#second')); // Shows second paragraph console.log($('#second').prev()); //Displays second, should show first paragraph console.log($('#second').next()); //Displays second, should show third paragraph </script>
Change History (3)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
My code actually breaks the adjacent sibling selector, so I don't recommend it. The existing code seems to work for everything except .next and .prev. For the life of me, I can't figure out why cur = cur[dir] doesnt get set in the for loop when using those functions...
Note: See
TracTickets for help on using
tickets.
After looking at the code, it appears that changing jQuery.nth's function definition to the following code appears to fix it. The for-loop and the cur[dir] assignment seems to have been broken. This may have some unknown impact on the selectors nth-child, first-child, last-child, but I will test those right now.