I have a tree of ul's that I want to search with jQuery and apply styles to those matching
so this:
Regional
|-InternetAccessGroup
|-Wasters
|-Packaging
|-Users
|-Students
|-Hello Fred
|-Package Student
|-Teachers
|-Package Teacher
|-Admins
|-Package Admin
is coded as this:
<ul id="browser" class="filetree">
<li ><span class="folder" id="Regional">Regional</span>
<ul id="browser" class="filetree">
<li class="closed" ><span class="group" id="InternetAccessGroup">InternetAccessGroup </span></li>
<li class="closed" ><span class="group" id="Wasters">Wasters </span></li>
<li class="closed" ><span class="folder" id="Packaging">Packaging</span>
<ul id="browser" class="filetree">
<li class="closed" ><span class="folder" id="Users">Users</span>
<ul id="browser" class="filetree">
<li class="closed" ><span class="folder" id="Students">Students</span>
<ul id="browser" class="filetree">
<li class="closed" ><span class="person" id="helloFred"id="Hello Fred ">Hello Fred </span></li>
<li class="closed" ><span class="person" id="student"id="Package Student ">Package Student </span></li>
</ul>
</li>
<li class="closed" ><span class="folder" id="Teachers">Teachers</span>
<ul id="browser" class="filetree">
<li class="closed" ><span class="person" id="teacher"id="Package Teacher ">Package Teacher </span></li>
</ul>
</li>
<li class="closed" ><span class="folder" id="Admins">Admins</span>
<ul id="browser" class="filetree">
<li class="closed" ><span class="person" id="packageadmin"id="Package Admin ">Package Admin </span></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
I want to (say) search for any entries containing the word "Package" (i assume with $("someselector:search('"+mysearch+"')"), and add the class "collapsible" to all parent li entries, and add the class "highlighted" to the actual matching entries. I know > is the jQuery child selector, but that seems to be only direct children, and what I'm doing as a jQuery newbie seems much harder. thing.addClas() is ok to me, but the selector part I cannot quite grasp.