So I am trying to add a class onto a UL depending on the text used in the navigation.
For example.
<li>
<a href="#">Text</a>
<ul>
</ul>
</li>
I want to add a class onto the ul depending on the text inside the a tag, to find the text I just use the a:contains method
$('#nav > li > a:contains("text")')
After that I draw a blank on how to add a class onto the ul that follows, I thought the .next might work but it turns out it doesn’t.
Any help would be greatly appreciated!
So, like:
? If the
<ul>could be anywhere after that, use:. Edit: Also,
Text‘s casing is wrong.:containsis case-sensitive (as others have pointed out now).