Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#189 closed bug (invalid)

prev() does not work as expected

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

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 (2)

comment:1 Changed 15 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 15 years ago by john

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.