-
Notifications
You must be signed in to change notification settings - Fork 0
/
LightSwitch.html
39 lines (37 loc) · 1.25 KB
/
LightSwitch.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Light Switch</title>
<style>
#bulb {
width: 133px;
height: 200px;
}
.sOn {
transform: rotate(180deg);
}
</style>
<script>
const on = "file:///C:/Users/daddi/Pictures/programming/WebDevClub/LightSwitch.html/on.jpg", off = "file:///C:/Users/daddi/Pictures/programming/WebDevClub/LightSwitch.html/off.jpg";
function switchLight() {
var img = document.getElementsByTagName("img");
if (img[0].currentSrc == off) {
img[0].src = on;
img[1].setAttribute("class", "sOn");
} else {
img[0].src = off;
img[1].setAttribute("class", "sOff");
}
}
</script>
</head>
<body>
<div id="bulb">
<img src="C:/Users/daddi/Pictures/programming/WebDevClub/LightSwitch.html/off.jpg"/>
</div>
<div id="switch">
<img src="C:/Users/daddi/Pictures/programming/WebDevClub/LightSwitch.html/switch.png" onclick="switchLight()"/>
</div>
</body>
</html>