糾結了兩天,憋出了個蛋,歡迎拍磚!!!
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
ul{margin:0;padding:0}
li{position:relative;margin:0;padding:0;;}
.grid{background:#ccc;width:100px;height:100px;;}
.f{background:#333;width:200px;height:200px;position:absolute;top:0;left:100px; display:none}
</style>
<script type="text/javascript" src="http://mat1.gtimg.com/www/js/tcomment/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
jQuery(function(){
window.a=0; window.b=1 ; //同為1隱藏彈層
$('ul').delegate('.grid','mouseover',function(){ // 鼠標放在頭像上
if($('.f')){
$('ul').append('<div class="f"></div>')
$('.f').css({top:$(this).offset().top})
}
window.a=0;
$('.f').show();
})
$('ul').delegate('.f','mouseover',function(){// 鼠標在彈層上
window.b=0;
});
$('ul').delegate('.grid','mouseout',function(){// 鼠標離開頭像
window.a=1;
})
$('ul').delegate('.f','mouseout',function(){// 離開彈層
window.b=1;
});
setInterval(function(){//console.log(window.a +" "+ window.b +" "+ window.c);
if(window.a&&window.b){
$('.f').hide();
}
},100)
})
</script>
</head>
<body>
<ul>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
<li><div class="grid"></div></li>
</ul>
</body>
</html>