Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript" src="http://www.senichi.nl/magento/js/jquery/jquery-1.4.4.min.js"></script>
  7. <script type="text/javascript">
  8.  
  9. $(document).ready(function() {
  10.  
  11. //Select all anchor tag with rel set to tooltip
  12. $('a[rel=tooltip]').mouseover(function(e) {
  13.  
  14. //Grab the title attribute's value and assign it to a variable
  15. var tip = $(this).attr('title');
  16.  
  17. //Remove the title attribute's to avoid the native tooltip from the browser
  18. $(this).attr('title','');
  19.  
  20. //Append the tooltip template and its value
  21. $("html").append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
  22.  
  23. //Set the X and Y axis of the tooltip
  24. $('#tooltip').css('top', e.pageY + 10 );
  25. $('#tooltip').css('left', e.pageX + 20 );
  26.  
  27. //Show the tooltip with faceIn effect
  28. $('#tooltip').fadeIn('500');
  29. $('#tooltip').fadeTo('10',0.8);
  30.  
  31. }).mousemove(function(e) {
  32.  
  33. //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
  34. $('#tooltip').css('top', e.pageY + 10 );
  35. $('#tooltip').css('left', e.pageX + 20 );
  36.  
  37. }).mouseout(function() {
  38.  
  39. //Put back the title attribute's value
  40. $(this).attr('title',$('.tipBody').html());
  41.  
  42. //Remove the appended tooltip template
  43. $("html").children('div#tooltip').remove();
  44.  
  45. });
  46.  
  47. });
  48.  
  49.  
  50. </script>
  51. <style>
  52. #test {
  53. display:block;
  54. width:300px;
  55. height:300px;
  56. font-family:Arial, Helvetica, sans-serif;
  57. font-size:18px;
  58. background-color:#069;
  59. margin-left:300px;
  60. text-decoration:none;
  61.  
  62. }
  63. #tooltip {
  64. position:absolute;
  65. z-index:9999;
  66. color:#fff;
  67. font-size:10px;
  68. width:180px;
  69.  
  70. }
  71.  
  72. #tooltip .tipHeader {
  73. display:none;
  74. }
  75.  
  76. /* IE hack */
  77. *html #tooltip .tipHeader {margin-bottom:-6px;}
  78.  
  79. #tooltip .tipBody {
  80. background:url(bg_tooltip.png); background-repeat:no-repeat;
  81. padding:5px;
  82. width:166px;
  83. height:37px;
  84.  
  85. }
  86.  
  87. #tooltip .tipFooter {
  88. display:none;
  89. }
  90.  
  91. </style>
  92. </head>
  93.  
  94. <body>
  95. <a rel="tooltip" Id="test" href="http://www.google.nl" title="Shop the end of season sale"></a>
  96. </body>
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement