On Mon, Mar 30, 2009 at 2:10 AM, Philippe Wittenbergh <[email protected]> wrote:
>
> On Mar 30, 2009, at 1:27 AM, Charles wrote:
>
>> How can I select an element combining nth-of-type() and a class/ID?
>> I tried for instance li.new:nth-of-type(2) but it doesn't work. You
>> can't combine both pseudo classes...
>> See: http://www.adsweep.org/nth-of-type-class-id.html
>> Any idea?
>
> You can certainly combine them.
>
> Your selector  translated:
> 'Selects any li element with a class attribute that contains the word new
> AND that is a second child of its type.'
> <http://gallery.theopalgroup.com/selectoracle/>
>
> The 2 conditions must be met: the element must have a class (.new) and it
> must be the second child of the ul in this case.  That would select the
> following:
> <ul>
> <li>foo</li>
> <li class="new">bar </li> <!-- this one -->
> <li>baz</li>
> <li class="new">.....</li><!-- NOT this one -->
> </ul>
>
> In your demo, those conditions are not met: the second child doesn't have a
> class (.new) appended. The element you want to select is not the second
> child. The nth-of-type (as with all those structural pseudo-classes) applies
> to element E (li, or ul, or p, or a, or tr, or h1, etc).
>
> BTW - you do know that browser support for those pseudo-classes is limited,
> do you ?
>
> Philippe
> ---
> Philippe Wittenbergh
> http://l-c-n.com/
>
>
>
>
>
>


Philippe,

I understand your rationale. Now, what if, among the list items that
have a "new" class, I want to select the second item? Please note in
my case there may be a variable number of list items before those that
have a "new" class, however, there is always the same number of list
items that have the class "new". So I can only start counting only
from the first item of those marked with the class "new", and I want
to pick the second item. How can I do that?

Yes, I am aware that stable versions of Firefox and Seamonkey (among
others) don't support these pseudo classes, but I need this only for
an ad-removal tool for other browsers (Opera and Chrome).
Thanks,

Charles-André Landemaine.
______________________________________________________________________
css-discuss [[email protected]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to