-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathjqueryevent.html
More file actions
51 lines (44 loc) · 1.23 KB
/
jqueryevent.html
File metadata and controls
51 lines (44 loc) · 1.23 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Example 2: Event Handling</title>
<script src="js/jquery-1.11.3.min.js"></script>
<script>
// Run after the ROM tree is constructed.
$(document).ready(function () {
// Set the content
$('#hello').html('Click me!');
// Bind a onclick handler to a selected element
$('#hello').click(function () {
$(this).html('Hello, world!');
return false; // Prevent triggering the default handler
});
// Bind onmouseover/onmouseout handlers to all selected elements
$('p').mouseover(function () {
$(this).addClass('green');
});
$('p').mouseout(function () {
$(this).removeClass('green');
});
});
</script>
<style>
.red {
color: #FF0000;
}
.green {
color: #00FF00;
}
.blue {
color: #0000FF;
}
</style>
</head>
<body>
<h1 id="hello"> </h1>
<p id="message" class="red">First Line </p>
<p class="red">Second Line </p>
<p>Third Line </p>
</body>
</html>