Skip to main content

Bug Tracker

Side navigation

#13721 closed bug (fixed)

Opened April 03, 2013 12:59PM UTC

Closed April 06, 2013 08:52PM UTC

Last modified April 06, 2013 08:56PM UTC

remove(":nth-child(1)") works differently than filter(":nth-child(1)").remove()

Reported by: Owned by: dmethvin
Priority: low Milestone: 1.10
Component: manipulation Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

First, a jsFiddle example :

In this jsFiddle, only the first child of each list should be removed.

According to the remove documentation, the remove method should do the same thing than applying first the filter method and then the remove method.

I think this is due to the fact that the remove function applies jQuery.filter in a loop for each element in the object so that each element becomes the first (:nth-child(1)) when the filter is called.

Line 5986 from

Attachments (0)
Change History (4)

Changed April 04, 2013 07:39PM UTC by dmethvin comment:1

component: unfiledmanipulation
priority: undecidedlow
status: newopen

Agreed. It *seems* like moving the filter outside the loop and removing that set would be better anyway ... so it must be a trap of some kind.

Changed April 05, 2013 01:36PM UTC by dmethvin comment:2

owner: → dmethvin
status: openassigned

Changed April 06, 2013 08:52PM UTC by Dave Methvin comment:3

resolution: → fixed
status: assignedclosed

Fix #13721. Filter before .remove() loop so positionals work. Close gh-1221.

Changeset: 1b610266502490eab42a0b9ddfac2f93da0b0fe1

Changed April 06, 2013 08:56PM UTC by dmethvin comment:4

milestone: None1.10

Fixed in master/2.0 per the above commit and cherry-picked into 1.x at