onmouseover和onmouseenter都是鼠标进入时触发,onmouseover在所选元素的子元素间切换的时候也触发!

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
border: 1px solid #aaa;
margin: 20px;
}
</style>
</head>
<body>
<div >
AA
<p>BB</p>
CC
</div>

<script>
var counter1 = 0
d1.onmouseover = function(){
counter1++;
console.log('COUNTER1:'+counter1);
}
//mouseover在子元素间切换时也会触发

var counter2 = 0
d2.onmouseenter = function(){
counter2++;
console.log('COUNTER2:'+counter2);
}
</script>
</body>
</html>

相关文章:

  • 2021-08-05
  • 2021-10-09
  • 2022-12-23
  • 2021-10-04
  • 2022-02-25
  • 2021-06-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-26
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
相关资源
相似解决方案