-
Notifications
You must be signed in to change notification settings - Fork 0
/
testjs03.html
35 lines (31 loc) · 737 Bytes
/
testjs03.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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Teste JavaScript</title>
<script type="text/javascript">
var quebrada = false;
function mudaLampada(tipo) {
if (tipo == 1) {
arquivo = "_imagens/lampada-acesa.jpg";
}
if (tipo == 2) {
arquivo ="_imagens/lampada-apagada.jpg";
}
if (tipo == 3) {
arquivo ="_imagens/lampada-quebrada.jpg";
}
if (!quebrada) {
document.getElementById("luz").src = arquivo;
if (tipo == 3) {
quebrada = true;
}
}
}
</script>
</head>
<body>
<h1>Acenda a Lâmpada</h1>
<img src="_imagens/lampada-apagada.jpg" id="luz" onmousemove="mudaLampada(1)"onmouseout="mudaLampada(2)" onclick="mudaLampada(3)"/>
</body>
</html>