Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  7. <style>
  8. div {
  9. position: relative;
  10. width: 50%; margin: auto; background: silver;
  11. }
  12. p {
  13. width: 300px; display: block; height: 150px; background: black; color: white;
  14. }
  15. .tooltip {
  16. width: 150px; height:auto;
  17. display: none;
  18. position: absolute;
  19. z-index: 99;
  20. background: gray;
  21. border-radius: 3px;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div>
  27. <p>This is the first paragraph</p>
  28. <p>This is the second paragraph</p>
  29. <p>This is the third paragraph</p>
  30. <p>This is the fourth paragraph</p>
  31. <p>This is the fifth paragraph</p>
  32. </div>
  33. <script>
  34. $(document).ready(function() {
  35. var $p = $("p"), This = $("this"),
  36. Target = {"src":""},
  37. tooltipSrc = Target.src,
  38. tooltip = $(document.createElement('p')),
  39. leftSub;
  40.  
  41.  
  42.  
  43. $p.mouseenter(function(e, Target) {
  44. Target = e.target;
  45. tooltip
  46. .attr({ class:"tooltip"})
  47. .text("this is a paragraph")
  48. .appendTo($("body"))
  49. .css({"display": "block"})
  50. $p.mousemove(function(e2) {
  51.  
  52. tooltip.css({
  53. "top": e2.pageY +15 , "left": e2.pageX + 15
  54. });
  55.  
  56. });
  57. $p.mouseleave(function() {
  58. tooltip.remove();
  59. });
  60. });
  61.  
  62. });
  63. </script>
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement