Last active
July 12, 2018 17:58
-
-
Save msafronov/f608ab6a9c7bb8d34c87148fe7405a94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page</title> | |
<style> | |
.parent { | |
width: 500px; | |
height: 500px; | |
border: 1px solid black; | |
} | |
.child1 { | |
width: 300px; | |
height: 300px; | |
background-color: green; | |
} | |
.child2 { | |
width: 100px; | |
height: 100px; | |
background-color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
<div class="parent"> | |
<div class="child1"> | |
<div class="child2"></div> | |
</div> | |
</div> | |
</div> | |
<script> | |
var parent = document.querySelector('.parent'); | |
function mouseEntry(e) { | |
if (e.target !== e.currentTarget) return; | |
if (!e.relatedTarget) return; | |
if (!e.relatedTarget.contains(e.currentTarget)) return; | |
console.log(e.type, e.target, e.currentTarget); | |
}; | |
parent.onmouseover = mouseEntry; | |
parent.onmouseout = mouseEntry; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment