添加mouseenter和mouseleave事件后,点击该元素(点击次数不确定),将触发mouseenter和mouseleave。
我尝试了chrome 62.0.3202.94(32),firework,IE,它只在chrome.Is上发生,是chrome的bug,还是我的代码有问题?
在线示例:http://runjs.cn/code/cbb0aw1a
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h4>click on the parent part,then see the console </h4>
<div class="parent" style="width: 100%;height: 100px;background-color: #ddd">
<div class="children" style="width: 50px;height: 50px;background-color: #d9534f;cursor: pointer">
test
</div>
</div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script>
$(".parent").mouseenter(function () {
console.log("enter")
}).mouseleave(function () {
console.log("leave")
});
</script>
</html>
https://stackoverflow.com/questions/47649442
复制相似问题