我有多个隐藏可见性的菜单(表单),我用图标上的点击事件打开它们。一切都很好,除了当我打开另一个菜单时前一个菜单仍然打开时,它们都保持可见。所以,我希望在打开新菜单时隐藏前菜单。
HTML
<span id='settingsIcon' class='settingsIcon'>S
<div class='settingForms'>
<div class='formMoveButton'>
<span class='settingsMakePublicIcon'>w</span>
<form action='' method='post' class='moveForm'>
<input class='settingsMakePublicButton' type='submit' value='Make public ' name='$this->move'/>
</form>
</div>
</div>
</span>
jQuery
$(".settingsIcon").click(function(event) {
event.stopPropagation();
if($(document).find(".settingForms").is(':visible') < 1) {
HandleSettingsWindow($($(this).children()[0]));
} else {
}
});
HandleSettingsWindow = function (el) {
$(document).click(function () { // Close the menu when clicked outside it
el.hide();
document.oncontextmenu = function () { return true; };
});
el.toggle();
}