This won’t really let you include more than one dropdown or make individual listeners for each individual element. You could do something like this to handle that:
Which will allow you to use it on multiple elements and it will the child submenu. You also have a lot of unnecessary CSS which actually makes the above look like it doesn’t work, but it does.
It needs more modification than this, but this should give you a start.
display: inline-block: /* changed */
Also, for quick online testing and sharing use JSFiddle or CodePen instead of putting files out there for someone to inspect source. CodePen links will actually embed into Discourse (the forum software Sitepoint uses)