14
rated 0 times
[
17]
[
3]
/ answers: 1 / hits: 8353
/ 10 Years ago, fri, october 17, 2014, 12:00:00
I have the following structure:
<div class=Downloadscontainer>
<ul>
<li>level 1</li>
<li><a href=#>level 1</a>
<ul>
<li>level 2</li>
<li>level 2</li>
<li><a href=#>some page</a>
<ul>
<li>level 2</li>
<li>level 2</li>
</ul>
</li>
</ul>
</li>
</ul>
And i am trying to display ul on click of its parent li, following is my jquery
$(document).ready(function () {
$(.Downloadscontainer ul li ul).css(display, none);
$(.Downloadscontainer li).each(function () {
$(this).click(function () {
if ($(this).children('ul').length > 0) {
$('.Downloadscontainer li ul').toggle();
}
});
});
});
So if I click on level 1 LI
it displays the UL
and then if I click on level 2 LI
which have UL
as well it close down the UL
of level 1 LI
; I would like it to keep opening the child UL
. How can I obtain this functionality ?
More From » jquery