Question about either Toggle or addClass
HI,
It would be awesome if someone could tell me how to approach this. I have an unordered list like this:
- <ul id="add_class_to_this">
- <li>
- <ul>
- <li> <a href="#" id="trigger>Trigger</a></li>
- <ul>
- <li>Other Stuff</li>
- <li>Other Stuff</li>
How would I go about making a toggle of some kind to add and remove a class from #add_class_to_this when #trigger is clicked the first, second time.
Also, there are going to be several of these <ul>'s on the same page, but the class that assigned to them will be the same. Also the structure will be the same. So, in other words, the parent <ul> of the child <li> will be where the class is applied. I hope this makes sense.
I know that I would have to give unique IDs, but was wondering if there was a short way to find a parent when there are several of the same structure on the page. Otherwise, I could probably just do a bunch of addClass and removeClass on the IDs, but that seems like a lot of jQuery to put on the page if there are going to be 9 of these lists that have to work this way.