I have a class .menu-departamento
and inside it I have a h3
and a ul li
, in which I'm putting a toogle
effect.
In the code below when I click on a h3
it displays all ul
and you want it to display only the ul
that is just below h3
clicked.
Follow the example below:
<div class="menu-departamento">
<h3>
cartuchos e toners
</h3>
<ul>
<li>01</li>
<li>02</li>
<li>03</li>
<li>04</li>
<li>05</li>
</ul>
<h3>impressoras</h3>
<ul>
<li>01</li>
<li>02</li>
<li>03</li>
<li>04</li>
<li>05</li>
</ul>
<h3>Cadernos</h3>
<ul>
<li>01</li>
<li>02</li>
<li>03</li>
<li>04</li>
<li>05</li>
</ul>
<h3>acessórios</h3>
<ul>
<li>01</li>
<li>02</li>
<li>03</li>
<li>04</li>
<li>05</li>
</ul>
</div>
<script>
$(document).ready(function(){
$('.menu-departamento > ul > li').hide();
$('.menu-departamento h3').click(function() {
$('.menu-departamento > ul > li').toggle('slow, 1000');
});
});
</script>
Sample reference in jsfiddle: link