Skip to main content

Bug Tracker

Side navigation

#11552 closed feature (duplicate)

Opened April 03, 2012 06:51PM UTC

Closed July 03, 2012 02:34AM UTC

Add support for :nth-of-type()

Reported by: wenz Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

The :nth-of-type CSS selector has been removed in jQuery 1.0. Given that recent browsers do support querySelector() and thus also support :nth-of-type(), I believe it would be a good idea to add :nth-of-type for legacy browsers. For instance, the example at http://jsfiddle.net/Kr5yN/3/ works in all current browsers and IE9+, but fails in IE6-8.

Attachments (0)
Change History (5)

Changed April 03, 2012 10:25PM UTC by sindresorhus comment:1

component: unfiledselector
priority: undecidedlow

Nothing has changed since it was removed. A fallback for legacy browsers is still needed, and it's still a pretty obscure selector, and not worth the extra bloat. In most cases nth-child can be used instead.

If you really need it with jQuery, you can use this plugin:

https://github.com/keithclark/JQuery-Extended-Selectors

or this:

http://css-tricks.com/snippets/jquery/add-nth-of-type-to-jquery/

Reasoning:

http://ejohn.org/blog/selectors-that-people-actually-use/

Changed April 04, 2012 12:13AM UTC by dmethvin comment:2

Seems like a rare selector need to me. If you're in a situation where all the platforms you support provide querySelectorAll you can use it.

Since this is really a Sizzle issue, I'll leave it open for timmywil's call.

Changed May 29, 2012 12:39AM UTC by timmywil comment:3

milestone: None1.next
status: newopen

I'm ok with adding it, but I think we should do some voting. There wouldn't be much extra bloat since we can reuse :nth-child's argument parsing, which has the same syntax.

Changed May 29, 2012 12:44AM UTC by dmethvin comment:4

I'm okay with it if it's only a few bytes, since it's a cross-browser issue.

Changed July 03, 2012 02:34AM UTC by timmywil comment:5

resolution: → duplicate
status: openclosed

This issue has been ported to a more widespread sizzle issue: https://github.com/jquery/sizzle/issues/44