-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjqDelegate.html
49 lines (46 loc) · 932 Bytes
/
jqDelegate.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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jquery delegate</title>
<style type="text/css">
#parent{
border:1px solid black;
padding:5px;
width:500px;
height:500px;
}
#child{
background:red;
width:100px;
height:100px;
}
.container{
}
.container li{
display:inline-block;
background:#eee;
}
</style>
</head>
<body>
<div id="parent">
<div id="child"></div>
</div>
<ul class="container">
<li>one</li><li>two</li><li>three</li><li>four</li><li>five</li>
</ul>
<script type="text/javascript" src="/static/js/lib/jquery.js"></script>
<script type="text/javascript">
$("#parent").delegate("#child","click",function(e){
alert("child is clicked");
})
function onload(){
alert(123);
}
window.onload=function(){
alert(456);
}
</script>
</body>
</html>