W3C home > Mailing lists > Public > www-style@w3.org > October 2008

Re: Selectors in jQuery

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 09 Oct 2008 13:05:32 -0400
Message-ID: <48EE39DC.4070505@mit.edu>
To: John Resig <jresig@mozilla.com>
CC: Daniel Glazman <daniel.glazman@disruptive-innovations.com>, www-style@w3.org

John Resig wrote:
> There is also :first and :last - and no they are not equivalent to
> using nth-child. They are scoped to the entire matched selector - for
> example doing 'div:first' would find the first div on the page - not
> all divs that are the first child element.

The thing with these is that in the context jQuery uses them in they're
really simple to implement (heck, document.querySelectorAll("...")[0]
for "...:first").  But if they're used to attach style, then dynamic
updates become a pain: any dynamic change that might add or remove nodes
needs to be compared to the position of the thing that matched the
:first, for example.

There would have to be some really convincing use cases for styling
here, and I'm not sure I see any offhand.

>> :input,
> 
> This is equivalent to (textarea, input, select, button)

But not <isindex> or <object> (the latter can submit, in theory).

> And this is equivalent to ([type=button], button)

But not input[type=submit] or input[type=reset]?

> I should note that :selected, in our case, refers to a selected
> option in a <select> element.

option:checked should work, in UAs that support that, as you note below.

-Boris
Received on Thursday, 9 October 2008 17:06:22 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:15 GMT