Jump to content


Recommended Posts



I have an unordered list with 5 classes (don't ask)..

<ul class="error_list reg_errors chpw_errors actv_errors profile_errors">

I have used .error_list:nth-child(1) to target reg_errors and .error_list:nth-child(2) to target chw_errors class.


How can I target the 5th class of this element without using :last-child? [i will be adding more classes to it]


I've tried


and it works, however it is also targeting the reg_errors class. I know this is a mess, but I can't find a better solution as I need to dynamically generate each class depending on the user's action.

Share this post

Link to post
Share on other sites

I'm not quite sure what you're asking here. Are you trying to target DOM elements with a class of 'reg_errors' and/or 'chpw_errors', or are you trying to target the selectors themselves? If I'm reading your post correctly, that's not how nth-child() works - take a look here and here.


Explain a bit more about what you're trying to do, what you expect to happen, and what's happening right now, and we'll be better able to help.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.