Bug Tracker

Modify

Ticket #189 (closed bug: invalid)

Opened 7 years ago

Last modified 6 years ago

prev() does not work as expected

Reported by: ieure Owned by:
Priority: major Milestone: 1.0
Component: core Version: 1.0
Keywords: Cc:
Blocking: Blocked by:

Description

prev() is supposed to return the unique preceding siblings of the selected set, but it doesn't work correctly. It seems to check the tag and/or class name instead of comparing the actual nodes.

E.g.:

<div>
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
    <span>5</span>
</div>

If you now do:

$('div span').hover(function()
{
    $(this).prev();
});

The returned set only contains the span node immediately preceding the hovered element, not every span node preceding it.

This happens in 1.0.1, by the way, though that's not an option in this form.

Change History

comment:1 Changed 7 years ago by joern

The discription of prev() is somewhat irritating: It states that it returns a set of elements. But in the next sentence, it says: It only returns the immediately previous sibling, not all previous siblings. I'm not sure about the intentions behind this, and if there is an easy way to do "prevs()" to return all previous siblings, not only the immediate.

comment:2 Changed 7 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid

This is correct, .prev() only retreives the single element preceding the current element - there is currently no way to select all preceding elements, but it's something that's going to be added very soon.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.