-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap_img.html
More file actions
41 lines (39 loc) · 1.12 KB
/
swap_img.html
File metadata and controls
41 lines (39 loc) · 1.12 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Swap Images</title>
<style>
.image-container {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
img {
width: 200px;
height: 200px;
object-fit: cover;
}
</style>
<script>
// Function to swap images
function swapImages() {
const image1 = document.getElementById("image1");
const image2 = document.getElementById("image2");
// Swap the src attributes of the two images
const tempSrc = image1.src;
image1.src = image2.src;
image2.src = tempSrc;
}
</script>
</head>
<body>
<h1>Image Swapper</h1>
<div class="image-container">
<img id="image1" src="hanumanji.jpg" alt="Image 1">
<img id="image2" src="shivji.jpg" alt="Image 2">
</div>
<button onclick="swapImages()">Swap Images</button>
</body>
</html>