Modify ↓
Ticket #6178 (closed bug: wontfix)
.parents() reverses element order
| Reported by: | RF | Owned by: | |
|---|---|---|---|
| Priority: | Milestone: | 1.4.2 | |
| Component: | traversing | Version: | 1.4.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Since jQuery 1.4, the parents() function reverses the order of the elements.
Example:
<html>
<head>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script language="JavaScript">
$(function(){
$("div span").parents("div").each( function() {
alert( $(this).text() );
} );
});
</script>
</head>
<body>
<div><span>eins</span></div>
<div><span>zwei</span></div>
<div><span>drei</span></div>
</body>
</html>
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Yep, this is intended - as with prevAll and prevUntil. Having them be reversed makes it much easier to access the intended value (for example, doing .parents(":first") will be equivalent to .parent()).