4
I have the following code:
Javascript test
<script>
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";
}
document.getElementById("luz").src= arquivo;
}
</script>
<body>
<h1>Acenda Lampada</h1>
<img src="_imagens/lampada-apagada.jpg" id="luz" onmouseover="mudaLampada(1)" onmouseout="mudaLampada(2)" onmouseclick="mudaLampada(3)">
</body>
The function works for type 1 and 2, but for type 3 nothing happens; can anyone find the error? Thanks.
Welcome to Stackoverflow English, take a tour to learn more about Sopt: https://answall.com/tour
– gato