- You can optionally set a data attribute so the dropdown will automatically match the width and margin of whatever element triggers it, like an input box.
- You don’t have to insert any css to make things show or hide (although the background of the dropdown is transparent by default, so you may want to give your dropdown div a background color at least).
- While this can just be used as a dropdown for whatever, I used it as a way to create a select box, where you can use checkboxes to select items (or multiple items). The script looks for checkboxes in the dropdown div. If it finds that there are checkboxes and the triggering element is an input box, it will automatically update the input box with the list of values as the user checks items.
- As mentioned, this isn’t specifically set up to be a dropdown selector, so it won’t autobuild the html for the checkboxes in the dropdown. I think it’s more flexible this way, and that way you can name the checkboxes and get the respective data however you want.