|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <title>jQuery UI Tooltip - Default demo</title> |
| 5 | + <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> |
| 6 | + <script type="text/javascript" src="../../jquery-1.4.2.js"></script> |
| 7 | + <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> |
| 8 | + <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> |
| 9 | + <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> |
| 10 | + <script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> |
| 11 | + <link type="text/css" href="../demos.css" rel="stylesheet" /> |
| 12 | + <script type="text/javascript"> |
| 13 | + $(function() { |
| 14 | + $("a, input").tooltip({ |
| 15 | + open: function() { |
| 16 | + var tooltip = $(this).tooltip("widget"); |
| 17 | + $(document).mousemove(function(event) { |
| 18 | + tooltip.position({ |
| 19 | + my: "left center", |
| 20 | + at: "right center", |
| 21 | + offset: "25 25", |
| 22 | + of: event |
| 23 | + }); |
| 24 | + }) |
| 25 | + // trigger once to override element-relative positioning |
| 26 | + .mousemove(); |
| 27 | + }, |
| 28 | + close: function() { |
| 29 | + $(document).unbind("mousemove"); |
| 30 | + } |
| 31 | + }); |
| 32 | + }); |
| 33 | + </script> |
| 34 | + <style> |
| 35 | + label { display: inline-block; width: 5em; } |
| 36 | + </style> |
| 37 | +</head> |
| 38 | +<body> |
| 39 | + |
| 40 | +<div class="demo"> |
| 41 | + |
| 42 | + <p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover |
| 43 | + the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip. |
| 44 | + </p> |
| 45 | + <p>But as it's not a native tooltip, it can be styled. Any themes built with |
| 46 | + <a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a> |
| 47 | + will also style tooltip's accordingly.</p> |
| 48 | + <p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p> |
| 49 | + <p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p> |
| 50 | + <p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p> |
| 51 | + |
| 52 | +</div><!-- End demo --> |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +<div class="demo-description"> |
| 57 | + |
| 58 | +<p>Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.</p> |
| 59 | + |
| 60 | +</div><!-- End demo-description --> |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +</body> |
| 65 | +</html> |
0 commit comments