← All challenges
Challenge
Dropdown Menu
Medium- javascript
- dom
Build a dropdown menu. A button opens a short list of options, and picking one closes the list and puts that choice on the button. A click anywhere outside the menu closes it too.
Notes:
- The starter has
#triggerand an empty#menulist that is hidden at first. Add the option items and the script.
Check your work against
- Clicking the trigger button opens/closes the menu
- Clicking anywhere outside the menu closes it
- Clicking a menu item closes the menu and shows the selected value on the trigger button
No automatic grading
Check your work against the list above, then compare it with the solution preview.
Tab indents. Press Esc, then Tab to leave the editor.
Live preview
Starter loaded. The preview updates as you type.