dropdown.html 708 B

123456789101112131415161718192021222324252627282930
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>dropdown</title>
  6. </head>
  7. <body>
  8. <!-- 1. Define some markup -->
  9. <button type="button">Select</button>
  10. <select>
  11. <option>Option 1</option>
  12. <option selected>Option 2</option>
  13. <option>Option 3</option>
  14. </select>
  15. <!-- 2. Include library -->
  16. <script src="../dist/select.js"></script>
  17. <!-- 3. Select! -->
  18. <script>
  19. var dropdown = document.querySelector('select');
  20. var button = document.querySelector('button');
  21. button.addEventListener('click', function(e) {
  22. var selected = select(dropdown);
  23. console.log(selected);
  24. });
  25. </script>
  26. </body>
  27. </html>