Need some help with JavaScript initialization in Magento 2

Hi, I’m trying to replace the standard menu in topmenu.phtml with a custom dropdown-menu. Therefore my plan was to use the dropdown-widget.

I put the HTML markup in topmenu.phtml which works fine but I don’t get the Javascript part. There is the documentation on how to initialize Javascript but I’m completely lost on this. How would I get the dropdown working? Putting

$('.magento__dropdown-widget').dropdown(); 

just in <script> tags does not work, obviously.

Would be very nice if someone could help me out. Thank you very much.

submitted by /u/zlep
[link] [comments]