I have a layout similar to this:
<tr>
<td class="topCategoryRow"><a href="javascript:void(0);" class="catlink">Some Category</a></td>
</tr>
<tr>
<td class="subCategoryRow">A sub category under Some Category</td>
</tr>
<tr>
<td class="subCategoryRow">Another sub category under Some Category</td>
</tr>
<tr>
<td class="topCategoryRow"><a href="javascript:void(0);" class="catLink">Another Category</a></td>
</tr>
<tr>
<td class="subCategoryRow">A sub category under Another Category</td>
</tr>
<tr>
<td class="subCategoryRow">Another sub category under Another Category</td>
</tr>
What I'm trying to do is attach a click handler on catLink classes. I want to be able to select the subCategoryRows under the topCategoryRows:
<script type="text/javascript">
$(function() {
$(".catLink").click(function() {
$(".subCategoryRow").show(); // This selector is wrong
});
});
</script>
The code I have selects ALL subCategoryRow's. I want to select only the ones under the category selected. Can someone help me build the correct selector?
<tr>s and not the<td>s?