-
Notifications
You must be signed in to change notification settings - Fork 26
/
mouseenter与mouseover的区别.html
50 lines (38 loc) · 1.03 KB
/
mouseenter与mouseover的区别.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>mouseover与mouseenter的区别demo</title>
<style type="text/css">
</style>
</head>
<body>
<span>mouseenter的效果:</span>
<ul id="testEnter">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
<span>mouseover的效果:</span>
<ul id="testOver">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
<script>
var test = document.getElementById("test");
testEnter.addEventListener("mouseenter", function( event ) {
event.target.style.color = "red";
setTimeout(function() {
event.target.style.color = "";
}, 500);
}, false);
testOver.addEventListener("mouseover", function( event ) {
event.target.style.color = "orange";
setTimeout(function() {
event.target.style.color = "";
}, 500);
}, false);
</script>
</body>
</html>