请教下mouseover()和mouseenter()之间的区别
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>demo009基础事件</title>
<script type="text/javascript" src="jquery-1.12.4.min.js"></script>
<style type="text/css">
#box1{
width: 200px;
height: 200px;
border:1px solid black;
}
#box2{
width: 100px;
height: 100px;
border:1px solid black;
position: absolute;
top: 300px;
}
</style>
</head>
<body>
<div id="box1">
<div id="box2"></div>
</div>
<script type="text/javascript">
/*$('#box1').mouseover(function(){
$('#box1').css('background','red');
});*/
$('#box1').mouseenter(function(){
$('#box1').css('background','red');
});
</script>
</body>
</html>
当把子元素box2定位到父元素外面的话,子元素鼠标移入使用monseenter()方法也会产生事件冒泡。但是不进行定位的话就不会产生冒泡。请问为什么?