这段代码经过演示,可以达到标题所说的效果,注意需要引入js文件
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery鼠标经过淡入显示提示框 演示</title>
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<style type="text/css">
.div{ border:1px solid #0000FF; float:left; width:200px; height:200px; margin:10px;}
div#tip{ position:absolute; width:100px; height:auto; border:1px solid #00CC66;}
.div1{border:0;cursor:pointer;width:auto; height:auto;}
</style>
</head>
<body>
<div id="tip" style="display:none">提示内容</div>
<div class="div"></div>
<div class="div"></div>
<div class="div div1">enenba</div>
<script type="text/javascript">
$(document).ready(function(){
$('.div').hover(
function(){
$('#tip').fadeIn('slow');
}
);
$('.div').mousemove(function(e){
var top = e.pageY+5;
var left = e.pageX+5;
$('#tip').css({
'top' : top + 'px',
'left': left+ 'px'
});
});
$('.div').mouseout(function(){
$('#tip').hide();
});
});
</script>
</body>
</html>