Reputation: 89
i need nested accordian menu so that i have followed this tutorial from this link. i have changed the jquery
$('li a').click(function (e) {
e.preventDefault();
var ullist = $(this).parent().children('ul:first');
ullist.slideToggle(); });
it is working but if i click child,parent can not be hide. can any one give me solution. please check this (http://jsfiddle.net/LgejL4oh/3/)
thank you
Upvotes: 0
Views: 90
Reputation: 5224
Well I managed to make it work. I make it work by doing ,
First Check if the Element being clicked has child ul:first
hidden or not.
visible
skip the toggle functionality(Means you are toggling on/off the same tab)toggle
all the other visible
element except the current one(So, If Company is previously visible hide it and display the current clicked tab )So, Here is the code ,
if (!$(this).parent().children('ul:first').is(":visible")) {
$(this).parent().parent().find("li").children('ul:visible').slideToggle();
}
var ullist = $(this).parent().children('ul:first');
ullist.slideToggle();
Upvotes: 2