Slide down and slide up with one link
Hi,
I'm really new to Javascript and jquery and I'm actually writing my first script.
It's for a navigation on my website. I want to have the sub-categories sliding down, if you click on a parent-category. I made it and there's no problem. But I want the sub-categories to slide away with a second click on the parent-category and I don't know how to do this.
to give you an example of my code:
the html:
-
<ul>
<li><a href="#">Home</a></li>
<li class="menuparent"><a class="menuparent2" href="#">Info</a>
<ul class="sub-categories">
<li><a href="#">News</a></li>
<li><a href="#">Calendar</a></li>
</ul>
</li>
<li><a href="#">Contact</a></li>
</ul>
and the js-file:
-
$(function() {
$('li.menuparent a.menuparent2').click(function() {
$('a.menuparent2 + ul.sub-categories').slideDown('fast');
});
});
I hope you can understand me (my english isn't so good) and I would be very glad if you could help me
