jquery悬浮提示框

来源:互联网 发布:自己设计房子软件 编辑:程序博客网 时间:2024/05/17 00:13


  1. <html>  
  2. <head>  
  3. <script type="text/javascript" src="jquery.js"></script>  
  4.     <script type="text/javascript">  
  5.         $(function() {  
  6.             x = 5;  
  7.             y = 15;  
  8.             $("p").hover(function(e) {  
  9.                 otitle = this.title;  
  10.                 this.title = "";  
  11.                 var ndiv = "<div id='leo'>" + otitle + "</div>";  
  12.                 $("body").append(ndiv);  
  13.                 $("#leo").css({  
  14.                     "top" : (e.pageY + y) + "px",  
  15.                     "left" : (e.pageX + x) + "px"  
  16.                 }).show(2000);  
  17.                 $(this).mousemove(function(e) {  
  18.                     $("#leo").css({  
  19.                         "top" : (e.pageY + y) + "px",  
  20.                         "left" : (e.pageX + x) + "px"  
  21.                     }).show(1000);  
  22.                 });  
  23.             }, function() {  
  24.                 this.title = otitle;  
  25.                 $("#leo").remove();  
  26.             });  
  27.         });  
  28.     </script>  
  29.     <style type="text/css">  
  30.         #leo {  
  31.             position: absolute;  
  32.             border: 1px solid grey;  
  33.             opacity: 0.8;  
  34.             background: grey;  
  35.         }  
  36.     </style>  
  37. </head>  
  38. <body>  
  39.     <p title="1dfgfdgdfg">If you click on me, I will disappear.</p>  
  40.     <p title="2dgfdgdfgdf">If you click on me, I will disappear.</p>  
  41.     <p title="3dgfdgfdgfder">If you click on me, I will disappear.</p>  
  42.     <p title="4ghfghfghfhgf">If you click on me, I will disappear.</p>  
  43. </body>  
  44. </html>


转自:blog.csdn.net/xpsharp/article/details/8307881
0 0
原创粉丝点击