VanityCrush Posted August 4, 2015 Share Posted August 4, 2015 Hello, 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 :nth-child(5n+1) 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. Quote Link to comment https://forums.phpfreaks.com/topic/297629-nth-child/ Share on other sites More sharing options...
Solution maxxd Posted August 6, 2015 Solution Share Posted August 6, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/297629-nth-child/#findComment-1518141 Share on other sites More sharing options...
mentalist Posted August 6, 2015 Share Posted August 6, 2015 That was my sentiment last night, not enough code to replicate the issue... Quote Link to comment https://forums.phpfreaks.com/topic/297629-nth-child/#findComment-1518153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.