执行以下操作的最简单方法是什么?
答案 0 :(得分:1)
我认为你正试图做到这一点:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
.red {
width: 200px;
height: 200px;
background-color: red;
}
.green {
display: none;
width: 200px;
height: 200px;
background-color: green;
}
.divider {
height: 200px;
}
</style>
</head>
<body>
<div class="red"></div>
<div class="divider"></div>
<div class="green"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".red").mouseenter(function(){
$(".green").show();
});
$(".green").mouseleave(function(){
$(".green").hide();
});
});
</script>
</body>
</html>