I’m trying to get a toggle effect but not quite sure how to do it or what to look for. (i jave Jquery loaded).
assume html similar to
<table class="left-dates">
<tr><td>All Dates</td></tr>
<tr><td>01 dec 2009</td></tr>
<tr><td>02 dec 2009</td></tr>
<tr><td>03 dec 2009</td></tr>
<tr><td>04 dec 2009</td></tr>
</table>
<div class="box 01-dec-2009">
foo
</div>
<div class="box 03-dec 2009">
bar
</div>
<div class="box 04-dec-2009">
foobar
</div>
Steps to take
- All div’s are shown
- Clicking on a td for a date will hide all but the div with the class of the day clicked
- clicking “All dates” will show everything again
any idea how i could achive this cleanly? ideally using JQuery.
Here is a working example with jQuery.
Note that I had to change your div classes and
tdlabels to remove whitespace so that the labels would be equivalent to the class-names. If you didn’t want dashes in the labels you could do string manipulation in Javascript to remove white-space or give thetds the same classname as their corresponding div and then look at the classname of the clickedtdrather than its inner-text.