Skip to main content

Bug Tracker

Side navigation

#189 closed bug (invalid)

Opened September 08, 2006 10:04PM UTC

Closed September 14, 2006 02:47AM UTC

Last modified June 21, 2007 03:01AM UTC

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.

Attachments (0)
Change History (2)

Changed September 09, 2006 11:03PM UTC by joern comment:1

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.

Changed September 14, 2006 02:47AM UTC by john comment:2

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.