08tooltip.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. <!-- data-placement: top, bottom, left, right, auto -->
  17. <button class="btn btn-default tooltipbutton"
  18. data-target="tooltip" data-placement="bottom"
  19. title="I am a <em>Bootstrap</em> button. Notice the italics." >
  20. Who am I ?
  21. </button>
  22. </div>
  23. <!-- https://ajax.googleapis.com/ajax/libs/jquery/1.11.1.jquery.min.js -->
  24. <script src="../js/jquery-1.11.2.min.js"></script>
  25. <script src="../js/bootstrap.js"></script>
  26. <script type="text/javascript">
  27. var options = {
  28. // Defaults to false
  29. animation: true,
  30. // A CSS selector, often "body". Unclear?
  31. // container: "body",
  32. // In msec. This is a delay, not a fade duration.
  33. delay: 1000,
  34. // Defaults to false
  35. html: true,
  36. // Can be used instead of data-placement attribute
  37. // placement: "top", "bottom", "left", "right", "auto"
  38. // CSS selector for child elements of the target on which to apply the tooltip
  39. // selector: 'a[href="hello.html"]'
  40. // Can be used instead of title attribute
  41. title: "Another way to set the tooltip text"
  42. // Defaults to "hover". Click is better on non-clickable elements.
  43. // trigger: "click" "focus", "hover", "manual"
  44. };
  45. // Also possible: options = "show"|"hide"|"toggle"|"destroy"
  46. $(document).ready(function() {
  47. $('.tooltipbutton').tooltip(options);
  48. });
  49. $(".tooltipbutton").on("show.bs.tooltip", function() {
  50. console.log('Showing tooltip');
  51. });
  52. $(".tooltipbutton").on("shown.bs.tooltip", function() {
  53. console.log('Tooltip shown');
  54. });
  55. $(".tooltipbutton").on("hide.bs.tooltip", function() {
  56. console.log('Hiding tooltip');
  57. });
  58. $(".tooltipbutton").on("hidden.bs.tooltip", function() {
  59. console.log('Tooltip hidden');
  60. });
  61. </script>
  62. </body>
  63. </html>