I'm implementing a function in my menu where it will close the contents of the dropdown
that is open IF the click is anywhere except in the menu itself.
$(document).click(function(event) {
var $menuOpened = $('.dropdown-content');
$.each($menuOpened, function(index, value) {
if ($(value).hasClass('show') && event.target != $(value)) {
// Fecha o menu
}
});
});
But I always true
when I click elsewhere, even the button responsible for opening the dropdown
in question, therefore, it is never displayed in order to be closed.
I have more than 1 dropdown that can be opened in the same menu.