Hello all, How is everybody doing today??
I am trying to get an unorderd list as trigger to toggle / expand some div's and I am struggling on this. Can someone point me in the right direction?
<div id="lost-and-found">
<ul>
<li><span><a href="#lost">Lost Animals</a></span>
<ul>
<li><a href="#lost_cats">Cats</a></li>
<li><a href="#lost_dogs">Dogs</a></li>
</ul>
</li>
<li><span><a href="#found">Found Animals</a></span>
<ul>
<li><a href="#found_cats">Cats</a></li>
<li><a href="#found_dogs">Dogs</a></li>
</ul>
</li>
</ul>
<div class="clear"> </div>
</div>
<div id="found">
<div id="found_cats">
<h2>Found Cats</h2>
<?php display_lf($found['cat']); ?>
</div>
<div id="found_dogs">
<h2>Found Dogs</h2>
<?php display_lf($found['dog']); ?>
</div>
</div>
<div id="lost">
<div id="lost_cats">
<h2>Lost Cats</h2>
<?php display_lf($lost['cat']); ?>
</div>
<div id="lost_dogs">
<h2>Lost Dogs</h2>
<?php display_lf($lost['dog']); ?>
</div>
</div>
<script>
$(function(){
$('#lost_cats, #found_cats, #lost_dogs, #found_dogs').hide();
$("#lost-and-found a").click(function(event) {
var href = $(this).attr('href');
$('#lost_cats, #found_cats, #lost_dogs, #found_dogs').hide();
$(href).show();
$(this).parent("div").show();
event.preventDefault();
});
});
</script>
The ul is 2 buttons (Lost / Found) with Cat and dog under each.
I have a div with id of lost and one with found. Inside each, there lost cat, lost dog and found cat, found dog respectively. I am trying to hide all sections initally with jquery and then open the lost / found section or the subsections of lost -> dog, lost -> cat, found ->dog, found -> cat.
Any tips / pointers will be appreciated.