-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path10_jquery_animation.html
More file actions
42 lines (41 loc) · 1.19 KB
/
10_jquery_animation.html
File metadata and controls
42 lines (41 loc) · 1.19 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Q.10 jQuery Animation Example</title>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<style>
#animatedBox {
width: 100px;
height: 100px;
background-color: blue;
position: relative;
}
</style>
</head>
<body>
<button id="animateButton">Animate Box</button>
<div id="animatedBox"></div>
<script>
$(document).ready(function () {
// Animate Box when the button is clicked
$('#animateButton').on('click', function () {
// Use the animate function to change CSS properties over time
$('#animatedBox').animate(
{
left: '+=150', // Move 150 pixels to the right
opacity: 0.5, // Change opacity to 0.5
width: '+=50', // Increase width by 50 pixels
height: '+=50', // Increase height by 50 pixels
},
1000,
function () {
alert('Animation complete!');
}
);
});
});
</script>
</body>
</html>