I have tried several different venues and ultimately came back to this which allows me to toggle them on and off individually but also I can open one dropdown and then also open another dropdown without the first closing. I want to be able to toggle them on and off as well as close all others when one is toggled on.
$('.list > li a').click(function () {
$(this).parent().find('ul').toggle();
});
Try this. Basically hide all toggles first and then show which is clicked. Note. I have removed the a tag and took the click on to the li element itself.
$('.list > li').click(function () {
$('.list li').hide();
$(this).find('ul').toggle();
});
Suggestion: Please share your html and jsfiddle link to get a better answer.
you can hide all other elements first and then toggle current element.
$('.list > li a').click(function () {
$('.list > li a').not(this).parent().find('ul').hide();
$(this).parent().find('ul').toggle();
});
I want to close the first nav dropdown when we open any other drop down currently I am using the elementor navbar. Check here https://kctherapy.com/our-team/ .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.