Skip to main content

Bug Tracker

Side navigation

#10922 closed bug (invalid)

Opened November 29, 2011 03:27PM UTC

Closed December 14, 2011 08:10AM UTC

parents() followed by add() or andSelf reverses order

Reported by: amannak@yahoo.com Owned by: amannak@yahoo.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

On jquery.com run

>>> $('#jq-learnNow').parents()
[div#jq-learnjQuery.jq-clearfix, div#jq-content.jq-clearfix, div#jq-siteContain, body.jq-enhanced, html.js]

adding .andSelf() reverses the list :(

$('#jq-learnNow').parents().andSelf()
[html.js, body.jq-enhanced, div#jq-siteContain, div#jq-content.jq-clearfix, div#jq-learnjQuery.jq-clearfix, div#jq-learnNow]

I want to do something like below but maintain the order i.e. reverse of what I am currently getting

>>> t = $('#jq-learnNow')
[div#jq-learnNow]
>>> t.add(t.parents())
[html.js, body.jq-enhanced, div#jq-siteContain, div#jq-content.jq-clearfix, div#jq-learnjQuery.jq-clearfix, div#jq-learnNow]
Attachments (0)
Change History (3)

Changed November 29, 2011 03:41PM UTC by amannak@yahoo.com comment:1

a work around

>>> t = $('#jq-learnNow').parents().toArray(); t.unshift($('#jq-learnNow')[0]); $(t);
[div#jq-learnNow, div#jq-learnjQuery.jq-clearfix, div#jq-content.jq-clearfix, div#jq-siteContain, body.jq-enhanced, html.js]

Changed November 29, 2011 05:36PM UTC by sindresorhus comment:2

owner: → amannak@yahoo.com
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

Changed December 14, 2011 08:10AM UTC by trac-o-bot comment:3

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!