Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera, é o seguinte: tenho um botão onn e um off. O que estou qurendo fazer é quando o on estiver apertado, ele acesse e fique com outro jpg. Quando eu clicar nele de novo, quero troque para outra tipo: on acesso e on apagado. Beleza. Daí também tem o off e vai fazer a mesma coisa, só que tem um porém, quando o on estiver em um estado, acesso o off apagado e vice-versa fiz um código mas estou sem a solução para a troca:
<html>
<head>
<script type="text/javascript">
//Botão 1
imagem1 = new Image();
imagem1.src = "1.jpg";
imagem1on = new Image();
imagem1on.src = "2.jpg";
//Botão 2
imagem2 = new Image();
imagem2.src = "light_off.jpg";
imagem2on = new Image();
imagem2on.src = "light_off_disabled.jpg";
//Botão 1
function ligado(imagem){
if (document.images) document[imagem].src = eval(imagem + "on.src");
if (document.getElementById("b1").src == "2.jpg") {
document.getElementById("b1").src = "1.jpg";
}
}
function off(imagem){
if (document.images) document[imagem].src = eval(imagem + ".src");
if (document.getElementById("b1").src == "1.jpg") {
document.getElementById("b1").src = "2.jpg";
}
}
//Botão 2
function desligado(imagem)
{
if (document.images) document[imagem].src = eval(imagem + ".src");
if(document.getElementById("b2").src == "light_off_disabled.jpg"){
document.getElementById("b2").src="light_off.jpg";
}
}
function desligadooff(imagem)
{
if (document.images) document[imagem].src = eval(imagem + "on.src");
if(document.getElementById("b2").src == "light_off.jpg"){
document.getElementById("b2").src="light_off_disabled.jpg";
}
}
</script>
</head>
<body><a href="#" onClick="desligado('imagem2')"
onClick="desligadooff('imagem2')">
<img name="imagem2" src="light_off_disabled.jpg" id="b2" border="0"></a>
</body>
</html>Carregando comentários...