-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhideAndShow.html
More file actions
38 lines (33 loc) · 937 Bytes
/
hideAndShow.html
File metadata and controls
38 lines (33 loc) · 937 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
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
button{
padding: 10px;
border-radius: 10px;
background-color: lightgray;
}
</style>
</head>
<body>
<button id="mybtn">Hide</button><br>
<img id="myimg" src="car-png.png" alt="" height="150px" width="300px">
<script>
const mybtn = document.getElementById('mybtn');
const img = document.getElementById('myimg');
mybtn.addEventListener('click', event =>{
if(img.style.display === 'none'){
img.style.display = 'block';
mybtn.textContent = "Hide"
}
else{
img.style.display = "none";
mybtn.textContent = "Show"
}
})
</script>
</body>
</html>