I want to do something similiar to a tree-view (really simpler)..
This is my effort: (When I click the first “parent-item it goes ok and reveals his “son”, but when I click the son, which is also a “parent-item”, it toggles back..
So I want something like that closest() function but for childs instead of parents..
jquery:
$(document).ready(function () {
$('#nav .parent-item').click(function () {
$(this).children('ul').slideToggle();
});
});
the html:
<ul id="nav">
<li>Atividade Recente</li>
<li class="parent-item">Projetos</a>
<ul>
<li class="parent-item"><a href="#">Renavam</a>
<ul>
<li>Atividade Recente</li>
<li>Conversação</li>
<li>Tarefas</li>
<li>Pessoa & Permissões</li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Minhas atividades</a></li>
Use
It finds all ‘ul’s below the context and the first() method limits it to just the first one