码迷,mamicode.com
首页 > 其他好文 > 详细

div跟随鼠标悬浮显示

时间:2015-02-26 14:57:18      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:javascript

<span style="font-size:18px;"><!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
<style>  
   #hint{  
    width:198px;  
    height:200px;
    border:1px solid #000000;  
    background:#99ff33;  
    position:absolute;  
    z-index:9;  
    padding:6px;  
    line-height:17px;  
    text-align:left;  
    top:1520px;  
   }  
</style> 
<script type="text/javascript">
 	function showme(){  
	     var oSon = window.document.getElementById("hint");  
	     if (oSon == null) return;  
	     with (oSon){  
	      	style.display = "block";  
	      	style.pixelLeft = window.event.clientX + window.document.body.scrollLeft + 6;  
	      	style.pixelTop = window.event.clientY + window.document.body.scrollTop + 9;  
	     }  
    }  

    function hideme(){  
	     var oSon = window.document.getElementById("hint");  
	     if(oSon == null) return;  
	     oSon.style.display="none";  
    }  
</script>
 <body>  
   <a href="#" onmouseover="showme()">测试div跟随鼠标悬浮显示1</a><br/><br/>
   <a href="#" onmouseover="showme()" onmouseout="hideme()">测试div跟随鼠标悬浮显示2</a><br/><br/>
   <a href="#" onmouseover="showme()" onmouseout="hideme()" onmousemove="showme()">测试div跟随鼠标悬浮显示3</a><br/><br/>
   <a href="#" onmouseover="showme()" onmouseout="hideme()" >测试div跟随鼠标悬浮显示4</a><br/><br/>
   <div id="hint" style="display:none" onmouseout="hideme()">
   		哈哈哈哈哈哈	
   		<input type="button" onclick="test()" value="按钮"/>
   		<a href="index.jsp">链接</a>
   </div>  
  </body>  
</html></span>

效果:

技术分享




div跟随鼠标悬浮显示

标签:javascript

原文地址:http://blog.csdn.net/xiaosheng_papa/article/details/43952665

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!