How do I change the class of the previous parent last-(or first) child
Hello,
I have code such as follows. I have labeled them with their correct indexes. I understand that the first ul tag is index 0, the second is index 1. I understand that the li is index 0 - 5 in each of the ul's. I have these set as buttons so when you click on them it removes a CSS class and then adds another CSS class. However due to scope if I click on the first-child in the second UL (or index 1 UL as labeled below) I cannot change the class of the first UL (Index 0 UL) last-child by using next() or prev().
Notes: I found that the slice function in combination with the each function will allow me to edit multiple children within different UL's without using indexes however it does ALL of them when all I really want is either the previous UL or the next UL depending on what was clicked.
If I click on Index 0 LI (in Index 1 UL) how do I change the class of Index 5 LI and Index 4 LI of the Index 0 UL?
- <ul> (Index 0 UL>)
- <li><li> (Index 0 LI>)
- <li><li> (Index 1 LI>)
- <li><li> (Index 2 LI>)
- <li><li> (Index 3 LI>)
- <li><li> (Index 4 LI>)
- <li><li> (Index 5 LI>)
- </ul>
- <ul> (Index 1 UL>)
- <li><li> (Index 0 LI>)
- <li><li> (Index 1 LI>)
- <li><li> (Index 2 LI>)
- <li><li> (Index 3 LI>)
- <li><li> (Index 4 LI>)
- <li><li> (Index 5 LI>)
- </ul>
- <ul> (Index 2 UL>)
- <li><li> (Index 0 LI>)
- <li><li> (Index 1 LI>)
- <li><li> (Index 2 LI>)
- <li><li> (Index 3 LI>)
- <li><li> (Index 4 LI>)
- <li><li> (Index 5 LI>)
- </ul>
Thanks for any assistance.
Wayne