<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-1.4a2.min.js"></script>
<style>
.a1 {
height:300px;
width:200px;
background-color:blue;
}
.a2 {
height:300px;
width:200px;
position:absolute;
top:20px;
left:200px;
background-color:blueviolet;
display:none;
}
</style>
</head>
<body>
<div class="a1"></div>
<div class="a2"></div>
<script>
$(".a1").mouseout(function () {
$(".a1").removeClass("hover");
setTimeout(function () {
if (!$(".a2").hasClass("hover"))
{
$(".a2").hide();
}
},500);
})
$(".a1").mouseenter(function () {
$(".a1").addClass("hover");
$(".a2").show();
})
$(".a2").mouseout(function () {
$(".a2").removeClass("hover");
setTimeout(function () {
if (!$(".a1").hasClass("hover")) {
$(".a2").hide();
}
}, 500);
})
$(".a2").mouseenter(function () {
$(".a2").addClass("hover");
$(".a2").show();
})
</script>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-1.4a2.min.js"></script>
<style>
.a1 {
height:300px;
width:200px;
background-color:blue;
}
.a2 {
height:300px;
width:200px;
position:absolute;
top:20px;
left:200px;
background-color:blueviolet;
display:none;
}
</style>
</head>
<body>
<div class="a1"></div>
<div class="a2"></div>
<script>
$(".a1").mouseout(function () {
$(".a1").removeClass("hover");
setTimeout(function () {
if (!$(".a2").hasClass("hover"))
{
$(".a2").hide();
}
},500);
})
$(".a1").mouseenter(function () {
$(".a1").addClass("hover");
$(".a2").show();
})
$(".a2").mouseout(function () {
$(".a2").removeClass("hover");
setTimeout(function () {
if (!$(".a1").hasClass("hover")) {
$(".a2").hide();
}
}, 500);
})
$(".a2").mouseenter(function () {
$(".a2").addClass("hover");
$(".a2").show();
})
</script>
</body>
</html>
本文介绍了一个使用jQuery实现的基本效果:当鼠标悬停在一个蓝色矩形上时,会显示另一个绝对定位的隐藏蓝色矩形;当鼠标移开时,该隐藏元素会在500毫秒后消失,除非鼠标仍在隐藏元素上。
1387

被折叠的 条评论
为什么被折叠?



