-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathhover.html
More file actions
70 lines (60 loc) · 1.63 KB
/
hover.html
File metadata and controls
70 lines (60 loc) · 1.63 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>hover</title>
<style type='text/css'>
body {font-family: verdana}
.error {border: solid 1px red;}
.error_text { color: red; font-size: 10px;}
td {padding: 3px;}
.hover, .hovers, .hoverleave {
border: solid 1px green;
margin:5px;
}
.hoverstate {
background-color: yellow;
}
.myhover {
border: solid 1px red;
}
</style>
</head>
<body>
<div id='demo-html'>
<h4>Delegating</h4>
<div class='hover'>hover me</div>
<div class='hover'>hover me</div>
<h4>Bound Directly</h4>
<div class='hovers'>hover me for a second</div>
<div class='hovers'>hover me for a second</div>
<h4>HoverLeave</h4>
<div class='hoverleave'>Leave and don't return for a half second</div>
</div>
<script type='text/javascript'
src='../../../steal/steal.js'></script>
<script type="text/javascript" id="demo-source">
steal('jquery/event/hover', function(){
// adds a hover class
var add = function(ev){
$(this).addClass("hoverstate");
};
// removes a hover class
var remove = function(ev){
$(this).removeClass("hoverstate");
};
// delegate on hover
$('.hover').live('hoverenter',add);
$('.hover').live('hoverleave', remove);
$('.hovers').bind('hoverinit',function(ev, hovered){
hovered.delay(1000);
});
$('.hovers').bind('hoverenter',add);
$('.hovers').bind('hoverleave', remove);
$('.hoverleave').bind('hoverinit',function(ev, hovered){
hovered.leave(500);
}).bind('hoverenter',add).bind('hoverleave', remove);
});
</script>
</body>
</html>