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

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -