javascript - Only one dropdown open at a time -


i noob i'm trying learn js. been toying around menu have been having trouble issue: using code, how implement behaviour of having 1 dropdown open @ time, on mobile?

$(".menu > ul > li").click(function () {     if ($(window).width() <= 943) {         $(this).children("ul").fadetoggle(150);     } }); 

this demo of code: http://jsbin.com/sesuda/edit?html,output

the way template works keeps dropdowns open.

what have tried: using not(this) open clicked dropdown item. also, using next(element) make next sibling (the dropdown content next dropdown link) visible.

any appreciated. disclaimer: sorry broken english, it's not native language , haven't slept 24h.

thank you.

you should fade out elements, , fade in clicked one

$(".menu > ul > li").click(function () {     if ($(window).width() <= 943) {         $(".menu > ul > li > ul").fadeout(150);         $(this).children("ul").fadetoggle(150);     } }); 

Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

file - Python: AttributeError: 'str' object has no attribute 'readlines' -

c# - Get the Class name in a class with atribute inside a attribute method -