Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery collapse table cells based on class

Tags:

html

jquery

Hi i have a table strcture for my menu, and i need to be able to collapse/expand the menu from level2, so that all level3 cells becone visible. My HTML is like this:

<table>
<tr><td class="level1"><a href="abc.html">First Item</a></td></tr>
<tr><td class="level2"><a href="def.html">SecondItem</a></td></tr>
<tr><td class="level3"><a href="ghi.html">Third Item</a></td></tr>
<tr><td class="level3"><a href="jkl.html">Fourth Item</a></td></tr>
<tr><td class="level3"><a href="mno.html">Fifth Item</a></td></tr>
<tr><td class="level2"><a href="pqr.html">Sixth Item</a></td></tr>
<tr><td class="level2"><a href="stu.html">Seventh Item</a></td></tr>
</table>

How do i, when i press the level2 item i only collapse/expand the level3 items following the level2 i pushed? I only want to do this for level2, not for level 1.

like image 849
Brian Hvarregaard Avatar asked Aug 14 '26 17:08

Brian Hvarregaard


1 Answers

Have you considered using nested lists for the menu? Not only does it make you task easier, but also is the "better" structure (Keyword: tableless layouts).

like image 77
RoToRa Avatar answered Aug 16 '26 06:08

RoToRa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!