02dropdown-js.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Blasting off with Bootstrap</title>
  5. <meta charset="utf-8" />
  6. <meta http-equiv="X-UA-COMPATIBLE" content="IE=Edge" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1" />
  8. <link rel="stylesheet" href="../css/bootstrap.min.css"/>
  9. <!--[if lt IE 9]>
  10. <script src="../js/html5shiv.3-7-0.js"></script>
  11. <script src="../js/respond.1-4-2.min.js"></script>
  12. <![endif]-->
  13. </head>
  14. <body>
  15. <div class="container">
  16. <div class="panel">
  17. <div class="dropdown" id="myDropdown">
  18. <!-- right-clicking this link to open in a new tab will take you to the href -->
  19. <a class="myDropdownHandle" href="http://google.fr"
  20. data-toggle="dropdown" data-target="#">
  21. Dropdown<span class="caret"></span>
  22. </a>
  23. <ul class="dropdown-menu">
  24. <li><a href="#">Item 1</a></li>
  25. <li><a href="#">Item 2</a></li>
  26. <li><a href="#">Item 3</a></li>
  27. <li><a href="#">Item 4</a></li>
  28. </ul>
  29. </div>
  30. </div>
  31. <!-- https://ajax.googleapis.com/ajax/libs/jquery/1.11.1.jquery.min.js -->
  32. <script src="../js/jquery-1.11.2.min.js"></script>
  33. <script src="../js/bootstrap.js"></script>
  34. <script type="text/javascript">
  35. $(document).ready(function () {
  36. $('#myDropdown .myDropdownHandle').dropdown('toggle');
  37. });
  38. $('#myDropdown').on('show.bs.dropdown', function () {
  39. console.log('Opening dropdown');
  40. });
  41. $('#myDropdown').on('shown.bs.dropdown', function () {
  42. console.log('Dropdown Opened');
  43. });
  44. $('#myDropdown').on('hide.bs.dropdown', function () {
  45. console.log('Hiding dropdown');
  46. });
  47. $('#myDropdown').on('hidden.bs.dropdown', function () {
  48. console.log('Dropdown hidden');
  49. });
  50. </script>
  51. </div>
  52. </body>
  53. </html>