A vanilla javascript dropdown library/plugin.
npm install @bluecoaster455/dropdownjshtml
...
...
`
Add a dropdown
Simply have a inside your with the dropdown attribute and an id.
Everything inside the is the content of your dropdown. You can override the styles
if needed.
The dropdown-container attribute defines the container of the dropdown and must not go
outside the container's boundaries (unless the dropdown is too big...)
`html
`
Add a dropdown trigger
Add a button in your HTML page and assign the dropdown-id attribute to open/close
the respective dropdown in the HTML. You can add more than one button to open/close
the same dropdown. The dropdown-align will align the dropdown to the button left or right
`html
`
DropdownJS API functions
`js
DropdownJS.show("dropdownid"); // display the dropdown by id.
DropdownJS.hide("dropdownid"); // hide a dropdown by id. You can specify nothing as id to hide all dropdowns.
DropdownJS.isOpen("dropdownid"); // checks if the dropdown is open.
DropdownJS.find("dropdownid"); // Find a dropdown by id and return a Dropdown instance.
DropdownJS.findByElement(document.querySelector("#dropdown")); // Find a dropdown by element.
``
Licence
DropdownJS is under MIT licence