I need to change top global navigation behavior from hover to onclick. The navigation pull down menu should open after a click on Level 1 item. To close the open menu I need to click somewhere outside this menu. How can I do that?
You can refer to this article:
About your requirement, you can use the Script Edit web part to add the Front-end code in the SharePoint site.
In this article, it offers a variety of menu dropdown styles, you can choose the appropriate code according to your requirement.