blob: cd16ae7ac83b92a906d5a172960b3b336832592c (
plain)
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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>register event</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
.normal {
background-color: gray;
width: 300px;
height: 200px
font-size: 1.5em;
}
.highlighted {
background-color: red;
}
</style>
<script type="text/javascript" src="jquery-2.0.2.js"></script>
<script type="text/javascript">
<![CDATA[
<!-- pass in an anonymous function to jquery, ha -->
$(function() {
<!-- http://api.jquery.com/on/ -->
$("#mdiv").on("mouseover mouseleave", highlight)
.on("click", function(event) {
$("#mdiv").off("mouseover mouseleave", highlight);
});
});
function highlight(event) {
$("#mdiv").toggleClass("highlighted");
}
]]>
</script>
</head>
<body>
<div id="mdiv" class="normal">
<p>This is some text. Mouseover here to fire an event. Click to suspend that handler.</p>
</div>
</body>
</html>
|