When visiting a website, you may notice menus that display sub-menus when hovered over. These menus and sub-menus are created using div elements, with the sub-menus hidden initially using style.display = none;
The issue arises when a sub-menu is opened and does not hide even when the user moves their mouse away from it. It remains open regardless of where the user clicks on the page.
I am seeking advice on how to implement functionality that will automatically hide the sub-menu after a certain amount of time or when the user clicks elsewhere on the page.
Please note: The mouseout event is not functioning as expected in this scenario.