-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsing.on().html
More file actions
31 lines (31 loc) · 956 Bytes
/
Using.on().html
File metadata and controls
31 lines (31 loc) · 956 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Jquery functions</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// $('.alert').click(function(){
// alert('you clicked me');
// });
$('.new_btn').click(function(){
$('#buttons').append("<button class='alert'>I am a dynamically generated button!</button>");
});
$(document).on('click', '.alert', function(){
alert('You clicked me!');
});
});
</script>
</head>
<body>
<h3>Static Content</h3>
<div>
<button class="alert">Click me for a message!</button>
<button class="alert">Click me for a message!</button>
<button class="alert">Click me for a message!</button>
<button class="new_btn">Click me to add a new button!</button>
</div>
<h3>Dynamically rendered content!</h3>
<div id="buttons"></div>
</body>
</html>