Menu
Dropdown
Press me to show dropdown
Press me to show dropdown
HTML
<x-dropdown type="button" id="dropdown"> <div id="title">Press me to show dropdown</div> <div id="menu-items"> <a href="#">Item 1</a> <a href="#">Item 2</a> <a href="#">Item 3</a> </div> </x-dropdown>
JavaScript
document.querySelector('#dropdown').bind([ () => { document.querySelector('#dropdown').close(); showSnackbar('Item 1 selected'); }, () => { document.querySelector('#dropdown').close(); showSnackbar('Item 2 selected'); }, () => { document.querySelector('#dropdown').close(); showSnackbar('Item 3 selected'); } ]);