nested.html 737 B

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