Hi guys. I have a lot of information on my site that is in multiple categories. I have a list of categories, each with its own checkbox. By default, all the information is displayed (therefore all the checkbox's are checked by default).
When someone unchecks the box I want to hide the divs with that class, and when someone rechecks the box, they should reappear. Here is my code so far. It is hiding the div's fine, but they are not reappearing when user tics the checkbox again.
Code:
<script type="text/javascript">
function toggledisplay(category){
if(document.getElementById(category).checked){
$("."+category).removeClass(category+"-hidden").addClass(category);
}
else{
$("."+category).addClass(category+"-hidden").removeClass(category);
}
}
</script>
<input type="checkbox" checked="checked" name="fitness" id="fitness" onclick="toggledisplay('fitness')" />