I'm attempting to use a side navigation to display table rows by category using jQuery.
<ul class="side-nav">
<li class="head">categories</li>
<li><a class="item" href="#">Show all</a></li>
<li><a class="accessories" href="#">Accessories</a></li>
<li><a class="books" href="#">Books</a></li>
<li><a class="electronics" href="#">Electronics</a></li>
<li><a class="dvd" href="#">Dvd</a></li>
<li><a class="misc" href="#">Misc.</a></li>
</ul>
<table>
<tr class="item misc.">
<td>1964 Jaguar model car</td>
<td>Misc.</td>
</tr>
<tr class="item dvd">
<td>Up(Pixar)</td>
<td>Dvd</td>
</tr>
<tr class="item electronics">
<td>Apple iMac</td>
<td>Electronics</td>
</tr>
</table>
Currently I'm using something like this and just repeating it for every category but these categories will eventually be added dynamically and this won't cut it. I know there's gotta be an easier way. Thanks for the help.
$('a.electronics').click(function() {
$('tr.item').hide();
$('tr.electronics').fadeIn();
});
$('a.item').click(function() {
$('tr.item').fadeIn();
});