Side navigation
#6178 closed bug (wontfix)
Opened February 25, 2010 10:43PM UTC
Closed February 26, 2010 05:38PM UTC
Last modified January 27, 2011 10:07PM UTC
.parents() reverses element order
| Reported by: | RF | Owned by: | |
|---|---|---|---|
| Priority: | Milestone: | 1.4.2 | |
| Component: | traversing | Version: | 1.4.1 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
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>
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()).