<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>鼠标移入移出事件</title>
<style>
*{
margin: 0;
padding: 0;
}
.father{
width: 200px;
height: 200px;
background: red;
}
.son{
width: 100px;
height: 100px;
background: blue;
}
</style>
<script src="../jquery-3.3.1.js"></script>
<script>
$(function () {
// $(".father").mouseover(function(){
// alert("father被移入了");
// });
// $(".father").mouseout(function(){
// console.log("father被移出了");
// });
//mouseover mouseout子元素会触发父元素事件
//mouseenter mouseleav 子元素不会触发父元素事件
// $(".father").mouseenter(function(){
// console.log("father被移入了");
// });
// $(".father").mouseleave(function(){
// console.log("father被移出了");
// });
$(".father").hover(function(){
console.log("father被移入了");
},function(){
console.log("father被移出了");
});
});
</script>
</head>
<body>
<div class="father">
<div class="son"></div>
</div>
</body>
</html>
jQery鼠标移入移出事件
最新推荐文章于 2024-08-09 18:00:00 发布